Using space-y-* utilities in reversed flex containers #3619
-
Code example: There is a design I'm working on that requires that some content be flipped in reverse on mobile screen sizes. As shown in the example code (mobile screen size), the margin between elements doesn't accommodate the new direction of the content inside the flex container in the middle column (Items 1-3). Any suggestions on how I can fix this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey! When using spacing utilities inside reversed flex containers, you can use the https://tailwindcss.com/docs/space#reversing-children-order Note - since you want to "un-reverse" them for the The below set of classes on your <article class="space-y-4 flex flex-col-reverse space-y-reverse lg:flex-col lg:space-y-4"> |
Beta Was this translation helpful? Give feedback.
Hey!
When using spacing utilities inside reversed flex containers, you can use the
space-{x/y}-reverse
utility:https://tailwindcss.com/docs/space#reversing-children-order
Note - since you want to "un-reverse" them for the
lg
breakpoint, you'll need to redeclare your spacing for the large breakpoint withlg:space-y-4
. This will redefine the--tw-space-y-reverse
CSS variable to be0
instead of1
.The below set of classes on your
<article>
tag will do the trick 👍