This repository demonstrates an uncommon bug encountered when using fractional widths (e.g., w-1/2
) within Tailwind CSS flexbox containers. The issue arises when the fractional widths don't seem to distribute the space correctly.
When two divs with w-1/2
are placed side by side in a flex container, one might expect them to occupy exactly half the available width each. However, this doesn't always happen, especially if there's other content affecting the container's dimensions.
The problem often stems from the implicit flex-shrink
and flex-grow
properties. Setting these explicitly to 0
ensures the divs maintain their fractional width without unwanted shrinking or expanding. Additionally, ensuring the parent container has the correct width to prevent unexpected behaviors can resolve the issue.
bug.html
in your browser. Observe the unequal spacing of the divs.bugSolution.html
to see the resolution.