Inconsistent spacing with space-y- class #18323
Unanswered
manueljenni
asked this question in
Help
Replies: 2 comments 1 reply
-
The spacing seems to be even in this Tailwind Play which would suggest it would be something particular to your project causing the unexpected behavior. Perhaps you have some extra CSS somewhere that applies margin to certain elements. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Inconsistent spacing with
space-y-2
classI'm having problems with space-y creating uneven spacing around elements.
Specifically, this:
creates more spacing around the top of the div containing the images than the bottom, which makes the whole layout seem off.
What version of Tailwind CSS are you using?
v4.1.4
What build tool (or framework if it abstracts the build tool) are you using?
Next.js 15.2.1 with PostCSS 8
What version of Node.js are you using?
v21.0.0
What browser are you using?
Chrome
What operating system are you using?
MacOS 15.4.1 (24E263)
Reproduction URL
example see below
Description
The
space-y-2
utility class in Tailwind CSS applies spacing only to the top of elements (except the first child), but not to the bottom. This creates inconsistent spacing when elements are followed by different types of content (e.g., paragraphs vs divs).Example
Current Behavior
space-y-2
class appliesmargin-block-start
to elements (except first child)margin-block-end
is appliedCSS that causes this (this adds the extra spacing on the top, but not the bottom)
I fixed this by adding the following:
Is this intended? Or a bug?
Beta Was this translation helpful? Give feedback.
All reactions