Skip to content

Paragraph with background has unwanted indentation when in group #55480

Open

Description

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:

Screenshot 2023-10-19 at 11 02 55

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:

Screenshot 2023-10-19 at 11 13 25

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    [Block] ParagraphAffects the Paragraph Block[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions