Skip to content

Commit 8723f91

Browse files
committed
[css-box-3] First draft of margin-trim. #3068 #2848
1 parent 021e7cd commit 8723f91

File tree

1 file changed

+87
-3
lines changed

1 file changed

+87
-3
lines changed

css-box-3/Overview.bs

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,87 @@ Margin Shorthand: the 'margin' property {#margin-shorthand}
281281
</pre>
282282
</div>
283283

284+
Margins at Container Edges: the 'margin-trim' property {#margin-trim}
285+
--------------------------
286+
287+
<pre class="propdef">
288+
Name: margin-trim
289+
Value: none | in-flow | all
290+
Initial: none
291+
Applies to: [=block containers=], [=multi-column containers=]
292+
Inherited: no
293+
Percentages: N/A
294+
Computed value: keyword as specified
295+
Animation type: discrete
296+
</pre>
297+
298+
Oftentimes, margins are desired between siblings,
299+
but not at the start/end of the container
300+
where spacing can be controlled with padding.
301+
This property allows the container
302+
to trim the margins of its children
303+
where they adjoin the container’s edges.
304+
Values have the following meanings:
305+
306+
<dl dfn-type=value dfn-for=margin-trim>
307+
<dt><dfn>none</dfn>
308+
<dd>
309+
Margins are not trimmed by the container.
310+
311+
Note: However, in block layout,
312+
child margins can collapse with their parent.
313+
See <a href="https://www.w3.org/TR/CSS2/box.html#collapsing-margins">CSS2&sect;8.3.1: Collapsing Margins</a>.
314+
315+
<dt><dfn>in-flow</dfn>
316+
<dd>
317+
For in-flow boxes contained by this box,
318+
block-axis margins adjacent to the box’s edges
319+
are truncated to zero.
320+
It also truncates any margins collapsed with such a margin.
321+
322+
<dt><dfn>all</dfn>
323+
<dd>
324+
Trims the margins of in-flow boxes as for ''in-flow'',
325+
but also trims any float margin
326+
whose [=margin edge=] coincides
327+
with the container’s [=content edge=].
328+
</dl>
329+
330+
Specifically, for [=block containers=],
331+
''margin-trim: in-flow'' or ''margin-trim: all'' discards:
332+
<ul>
333+
<li>The block-start margin of a block-level first child.
334+
<li>The block-end margin of a block-level last child.
335+
<li>Any margin collapsed with these margins.
336+
</ul>
337+
338+
''margin-trim: all'' also affects floats
339+
for which the [=block container=] is a [=containing block=] by:
340+
<ul>
341+
<li>
342+
Discarding the [=block-start=] [=margin=] of any float
343+
whose [=block-start=] [=outer edge=] coincides
344+
with the [=block-start=] [=inner edge=] of the container.
345+
<li>
346+
Discarding the [=inline-start=]/[=inline-end=] [=margin=]
347+
of an [=inline-start=]/[=inline-end=] float (or equivalent)
348+
whose [=outer edge=] on that side coincides
349+
with the [=inner edge=] of the container.
350+
<li>
351+
Zeroing the [=inline-axis=] margins of a float
352+
for the purpose of calculating its [=intrinsic size contributions=]
353+
or its [=size=] in the container’s [=inline axis=].
354+
<li>
355+
Trimming the [=block-end=] margins of a float
356+
to the extent necessary to prevent such a margin
357+
from extending the [=block size=]
358+
of a [=block formatting context root=].
359+
</ul>
360+
361+
ISSUE: Should this property apply to [=flex containers=] or [=grid containers=]?
362+
363+
ISSUE: Should floats have a <css>floats</css> value that only affects floats?
364+
284365
Padding {#paddings}
285366
=======
286367

@@ -374,9 +455,12 @@ Padding Shorthand: the 'padding' property {#padding-shorthand}
374455
Changes Since CSS Level 2 {#changes}
375456
=========================
376457

377-
There are no non-editorial changes since CSS Level 2,
378-
other than adapting the prose slightly to account
379-
for vertical <a>writing modes</a>.
458+
The following changes have been made to this module
459+
since <a href="https://www.w3.org/TR/CSS2/box.html">CSS Level 2</a>:
460+
<ul>
461+
<li>Adding the 'margin-trim' property.
462+
<li>Adapting the prose slightly to account for vertical <a>writing modes</a>.
463+
</ul>
380464

381465
Privacy and Security Considerations {#priv-sec}
382466
===============================================

0 commit comments

Comments
 (0)