Re: [csswg-drafts] [css-align] gap properties for block layout

The CSS Working Group just discussed `gap properties for block layout`, and agreed to the following:

* `RESOLVED: Add the margin-trim property with values [ none | in-flow | all ] to css-box-3`
* `RESOLVED: margin-break controls not just margins at fragmentation breaks, but also at the beginning and end of the fragmentation chain`

<details><summary>The full IRC log of that discussion</summary>
&lt;heycam> Topic: gap properties for block layout<br>
&lt;fantasai> github: https://github.com/w3c/csswg-drafts/issues/3068<br>
&lt;fantasai> https://github.com/w3c/csswg-drafts/issues/2848<br>
&lt;heycam> fantasai: basically the request from authors is to get rid of the margin at the very top and bottom of an element<br>
&lt;heycam> ... so top before the first element, and bottom of the last element<br>
&lt;heycam> ... suggestion in one is to have a different box-sizing value of some kind<br>
&lt;heycam> ... other suggestion was can we have gaps to do this, add gaps to block layout<br>
&lt;heycam> ... I don't thinkI want to add gaps to block layout<br>
&lt;heycam> ... margin collapsing is its own special thing, fairly complicated<br>
&lt;heycam> ... but we can solve the problem by having a property that gets rid of the margins in the interior of an element<br>
&lt;heycam> ... I think tables do this automatically in quirks mode<br>
&lt;heycam> ... so this proposal is to add a property that would do this, and have an on/off switch, or do it for all items, or only in flow items, or something<br>
&lt;heycam> ... I want to see what people think about this, and whether to add it to the css-box-3 spec<br>
&lt;heycam> TabAtkins: we already have a use case for it in css specs themselves<br>
&lt;heycam> ... notes, examples, etc. have a :first-child { margin-top: 0 } rule, which works unless you start the element with raw text<br>
&lt;heycam> ... so the necessity of making this actually robust seems fairly clear to me<br>
&lt;fantasai> https://github.com/w3c/csswg-drafts/issues/3068#issuecomment-417486499<br>
&lt;heycam> fantasai: there's a rough proposal in this comment<br>
&lt;fantasai> margin-trim: none | in-flow | all<br>
&lt;heycam> ... up for bikeshedding, etc., but that's the starting point proposal<br>
&lt;heycam> florian: that would work on elements that establish a BFC?<br>
&lt;Jia_An> join #tpac-chat<br>
&lt;heycam> fantasai: yes, also reasonable to do on flex containers<br>
&lt;heycam> TabAtkins: does it work on blocks taht don't establish a BFC?<br>
&lt;heycam> fantasai: yes<br>
&lt;heycam> s/taht/that/<br>
&lt;heycam> iank_: is this the same thing as the -webkit-margin-collapse?<br>
&lt;heycam> TabAtkins: I don't know what those are<br>
&lt;heycam> fantasai: it doesn't control collapsing, it switches to discarding<br>
&lt;heycam> TabAtkins: might just be a terminology issue<br>
&lt;heycam> ... I don't know what those properties do<br>
&lt;heycam> iank_: I believe one of the values nukes the whole margin collapsing result<br>
&lt;heycam> ... and just makes it go to 0<br>
&lt;heycam> fantasai: this is different in that it keeps the margin of the element itself, it kills the margin of its first child<br>
&lt;heycam> TabAtkins: the reason why this is important, rather than putting prop on first child, is when the first child is a text node<br>
&lt;heycam> ... if there's an element right after that you want to keep the margin<br>
&lt;heycam> ... either that or have the ability to target text node, which I would rather avoid<br>
&lt;heycam> iank_: is there an example of that in an issue somewhere?<br>
&lt;heycam> TabAtkins: I'll find one<br>
&lt;fantasai> &lt;div><br>
&lt;fantasai>   some text<br>
&lt;fantasai>   &lt;p>more text&lt;/p><br>
&lt;fantasai> &lt;/div><br>
&lt;fantasai> &lt;div><br>
&lt;heycam> florian: if you select the first child with a selector, it might be display none, which would do the wrong thing<br>
&lt;fantasai>   &lt;p>some text&lt;/p><br>
&lt;fantasai>   &lt;p>more text&lt;/p><br>
&lt;fantasai> &lt;/div><br>
&lt;heycam> eae: sounds like a good idea<br>
&lt;heycam> ... would like to see an example<br>
&lt;heycam> fantasai: in this example, in either case, you don't want margins at the top and bottom of htethe div<br>
&lt;heycam> ... you just want the margin to go away because you've specified how much space you want between the border hwich is visisble, and hte text which is visible<br>
&lt;heycam> ... if you were trying to rely on hte :first-child selector, you could not do this correctly<br>
&lt;heycam> ... since it would select the &lt;p><br>
&lt;heycam> ... which is after some amount of text<br>
&lt;heycam> ... this is the example Tab pulled from the specs<br>
&lt;fantasai> s/is visible/is visible as 'padding'/<br>
&lt;heycam> TabAtkins: it ends up happening rarely in CSS, since it relies on the first text child not having links in it<br>
&lt;heycam> ... which is rare<br>
&lt;heycam> Rossen: what spec is this going in?<br>
&lt;heycam> fantasai: I would suggest css-box-3, which has no new features right now<br>
&lt;heycam> ... it's just what's in CSS 2 with updated terminoligy<br>
&lt;fantasai> https://www.w3.org/TR/css-box-3/<br>
&lt;heycam> TabAtkins: I agree<br>
&lt;heycam> Rossen: would margin-break go there too?<br>
&lt;heycam> fantasai: there or fragmentation level 4<br>
&lt;heycam> ... which is where box-decoration-break is<br>
&lt;heycam> ... should xref from here for sure<br>
&lt;heycam> Rossen: proposal is to add margin-trim with the values as above<br>
&lt;heycam> TabAtkins: does the all value affect all floats touching the start edge of the container?<br>
&lt;heycam> ... want to make sure that's a reasonable thing to do<br>
&lt;heycam> iank_: I'll have to check<br>
&lt;heycam> Rossen: should be straightforward<br>
&lt;heycam> ... you're positioning your floats in the beginning of your container, and at that time you can decide to trim the margin<br>
&lt;heycam> ... you're not going to affect anything below you at this point<br>
&lt;heycam> ... the thing that will be a bit iffy is when you start pushing margins to the next line<br>
&lt;heycam> ... want to make sure you're not losing the margins, but these are impl details<br>
&lt;heycam> fremy: does the all value also affect the margin at the bottom of a float?<br>
&lt;heycam> ... that seems more problematic<br>
&lt;heycam> ... you don't know when you place the float if you're going to be at the bottom of the element<br>
&lt;heycam> fantasai: if you get to the bottom and the float is what it's causing it to be taller, you can back up to the border edge<br>
&lt;heycam> ... but you're right that is a trickier situation than the top<br>
&lt;heycam> florian: if the margin of the float is pushing the bottom edge, and you can just remove it by changing the rest of the layout, it's fine<br>
&lt;heycam> ... but if removing it entirely, some lines could intrude where they couldn't before<br>
&lt;heycam> ... trim only the amount of the margin that is extending<br>
&lt;heycam> iank_: does this eat just the first and last margin of the first element? or eat the whole collapsing margin?<br>
&lt;heycam> fantasai: the whole collapsed margin<br>
&lt;heycam> florian: the element, its first child, etc., as long as they're collapsing<br>
&lt;heycam> Rossen: just to be sure, when we talk about the first float, we're talking about floats that are at the beginning? two or many adjacent?<br>
&lt;heycam> florian: yes because your goal is to get visual alignment<br>
&lt;heycam> Rossen: just want to be explicit since we keep talking about "the first"<br>
&lt;heycam> ... but with float you can have many<br>
&lt;heycam> TabAtkins: all margins touching the start edge<br>
&lt;heycam> RESOLVED: Add the margin-trim property with values [ none | in-flow | all ] to css-box-3<br>
&lt;heycam> florian: now that we have this and the thing we resolved on before the break, discarding margins around frag breaks, if we go back to Jen's use case<br>
&lt;heycam> ... the first para of first multicol column, we can address it with the thing we just created<br>
&lt;heycam> ... maybe we should also address it with the margin-break thing we were discussing<br>
&lt;heycam> fantasai: I think I would lean towards having both of those properties controlling this particular break<br>
&lt;heycam> florian: in the frag context, you probably want the same beahvioru after the first forced break, and at the beginning<br>
&lt;heycam> ... because there's no desire for the second chapter to look different from the first chapter<br>
&lt;TabAtkins> http://software.hixie.ch/utilities/js/live-dom-viewer/saved/6305 &lt;-- an example of the "zero out the margins of first/last child" strategy giving bad results<br>
&lt;heycam> florian: the summary is that margin-break, the value that causes the margin to be discarded causes it to be discarded not only after breaks, but also at the beginning of the first fragmentainer<br>
&lt;heycam> s/margin-break/margin-break:discard/<br>
&lt;heycam> ... when you explicitly opt in to discarding things, not only discard around breaks, but also at the start<br>
&lt;jensimmons> and at the end?<br>
&lt;heycam> ... effectively you count the start as a forced break<br>
&lt;heycam> fantasai: proposed resolution is that margin-break controls not just margins at fragmentation breaks, but also at the beginning and end of the fragmentation chain<br>
&lt;heycam> Rossen: and this will be an additional requirement on margin-break?<br>
&lt;heycam> fantasai: yes<br>
&lt;heycam> Rossen: and this also applies at the end, not just the start<br>
&lt;heycam> RESOLVED: margin-break controls not just margins at fragmentation breaks, but also at the beginning and end of the fragmentation chain<br>
&lt;gregwhitworth> florian &amp; fantasai: is there a reason that we NEED two seperate properties that are doing the same thing, just in two different contexts?<br>
&lt;fantasai> gregwhitworth, yes, you want to control behavior at breaks and behavior of a container separately<br>
&lt;fantasai> gregwhitworth, also one applies to the element's own margins and one applies to its contents :)<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3068#issuecomment-431777940 using your GitHub account

Received on Monday, 22 October 2018 10:09:51 UTC