Description
openedon Oct 19, 2023
Steps to reproduce:
Create a series of paragraphs, add background color to some of them, and put some of them into a group. The result looks like this:
Now what I perceive as buggy is the alignment of the last paragraph, the one with background color, inside the group. The first letter should be on the same vertical line as the preceding paragraphs, but instead it's indented by the .has-background
style's padding. This shouldn't happen. The .has-background
style is there to create some "breathing space" around the colored block, but on the horizontal axis, it should "stick out" of the layout, just like the top-level paragraph does.
The bug is caused by the interaction between the parent container's width (max-width
) and the child element's padding
. You don't even need an inner group to reproduce it, just make the top-level container narrow enough:
Now both colored paragraphs are misaligned.
One way to fix this would be to use box-shadow
, maybe in combination with a non-collapsible vertical margin
. The following styling achieves almost the same effect as the padding
, but better:
.has-background {
margin-top: 10px;
margin-bottom: 10px;
}
.has-red-background-color {
background-color: red;
box-shadow: 0 0 0 10px red;
}
Removing and/or customizing the .has-background
padding is also discussed in #51323.