Skip to content

Commit 146144f

Browse files
Loirooriolservo-wpt-sync
authored andcommitted
layout: Let stretch on flex item cross size stretch to the line
We were instead stretching to the containing block, which implied that the behaviors of a `stretch` size and `stretch` alignment weren't consistent. As resolved by the CSSWG, the behavior will now be: - If the cross size of the line is known, stretch to the line. - Otherwise, stretch to the containing block. This aligns us with Blink, which has already shipped this new behavior. Signed-off-by: Oriol Brufau <[email protected]>
1 parent ba69c4e commit 146144f

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

css/css-flexbox/align-self-016.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Flexbox: shrink-to-fit item in multi-line column container</title>
4+
<link rel="author" title="Oriol Brufau" href="mailto:[email protected]">
5+
<link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#propdef-align-self">
6+
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/11784">
7+
<link rel="match" href="../reference/ref-filled-green-200px-square.html">
8+
<meta assert="
9+
#item has `align-self: start`, which sizes it as `fit-content`.
10+
Therefore, we initially shrink-to-fit it into the container (100px),
11+
thus getting a cross size of 100px and a main size of 200px.
12+
However, we have another item which is 200px wide, so the flex line
13+
grows to that size.
14+
Once we know the final cross size of the line, we shrink-to-fit #item
15+
into the line (200px), thus getting a final cross size of 200px.
16+
Now both floats fit side by side into these 200px, so vertically they
17+
only need 100px, but the main size of #item remains as 200px.
18+
">
19+
20+
<style>
21+
#container {
22+
display: flex;
23+
flex-flow: column wrap;
24+
width: 100px;
25+
border-right: 100px solid red;
26+
}
27+
#item{
28+
align-self: start;
29+
background: linear-gradient(to bottom, red 50%, green 50%);
30+
}
31+
.float {
32+
float: left;
33+
width: 100px;
34+
height: 100px;
35+
background: green;
36+
}
37+
</style>
38+
39+
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
40+
<div id="container">
41+
<div id="item">
42+
<div class="float"></div>
43+
<div class="float"></div>
44+
</div>
45+
<div style="width: 200px"></div>
46+
</div>

0 commit comments

Comments
 (0)