Open fantasai opened 2 years ago
If margin-trim
affects inline-level contents, then I think that anonymous block containers should inherit margin-trim
. Otherwise it would stop working if you add a block-level child, which will then cause the inline-level children to be wrapped inside an anonymous block.
trimming inlines in the block axis seems better served by leading-trim and other specialized text-sensitive things
I think that trimming inline-level contents in the block axis can make sense if they are inline-blocks.
Hi,
I tried to use margin-trim, but it seems it only trim margins of block children. This caught me a bit by surprise and reduce a lot the use cases of this feature. For instance here we have a label set in inline-block with a margin-block-start, I would have assumed margin-trim to cut the margin... but it's not happening unless the label is block (but this cause other issues as it would expand to the whole container):
What is the rationale for not removing margin in this situation?
@bakura10 Not sure exactly what you're trying to do, but maybe a combination of display: block; width: fit-content
would get you what you want here?
Proposed to close "effect on descendant inlines' as wontfix due to Oriol's observation that applying to inlines won't work as expected given descendant (potentially anonymous) blocks (since it won't inherit into those blocks).
The use case is adequately handled by margin-break
, though, so we should add an example to that spec.
Since this was your proposal and an example does not need a working group resolution, I think you should feel empowered to close this issue without adding it to the agenda.
@astearns Adding an example doesn't, but I do want to confirm that we're ok to spec
margin-trim
on a block container has no effect on its inline contentmargin-trim
on a block container only affects the block-axis margins of its block-level content, even when margin-trim: inline
is specified.And also, upon review, there's still the original open question of, do we want this to have an effect when specified on inline boxes.
@fantasai the display: block; width: fit-content would not work here. The idea is to be able to control the text positioning at the parent level, using a text-align: center. But I can understand this is causing too much complexities, so if this is works as per the spec then we can close it :)
The CSS Working Group just discussed [css-box-4] Applying margin-trim to inlines
, and agreed to the following:
RESOLVED: margin-trim has no effect on the inline axis of a block container
RESOLVED: margin-trim on a containing block does not affect inline-level content
We've defined 'margin-trim' to accept a list of sides to trim, with options for all four sides. For block containers (which previously only trimmed the block-start and block-end sides) there are a few interesting open questions:
My proposed answer to this, btw, is that margin-trim applies to inlines in the inline axis, and to blocks in the block axis, and not to inlines in the block axis or to blocks in the inline axis. Reason being, these are the two things that seem useful.
Trimming blocks in the inline axis isn't very useful (they're always adjoining both sides, so just set your margins to zero) and trimming inlines in the block axis seems better served by leading-trim and other specialized text-sensitive things. Proposed definition means we can turn on the useful behaviors (inline-axis trimming of inlines, block-axis trimming of block) without simultaneously turning on unwanted behaviors (block-axis trimming of inlines, inline-axis trimming of blocks).