Skip to content

Commit 548df24

Browse files
committed
fix: stop heading overlapping an image that directly follows it
The -10px negative margin-bottom on h2/h3 (meant to tighten heading-to-paragraph spacing) had no line-height leading to absorb it when the next sibling was a bare <img>, so the image overlapped the heading. Restore a normal 16px gap for the heading-directly-followed-by-image case via :has(+ img).
1 parent a0232e0 commit 548df24

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/styles/index.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ h6 {
6868
margin-bottom: -6px;
6969
}
7070

71+
/* When a heading is directly followed by an image (not a text paragraph),
72+
there is no line-height leading to absorb the negative margin above, so
73+
the image overlaps the heading. Restore a normal gap for that case only. */
74+
:is(h2, h3, h4, h5, h6):not(:first-child):has(+ img) {
75+
margin-bottom: 16px;
76+
}
77+
7178
h1 {
7279
font-size: clamp(32px, 5vw, 52px);
7380
font-weight: 800;

0 commit comments

Comments
 (0)