-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
grid-intrinsic-track-sizes-001.html
93 lines (78 loc) · 3.81 KB
/
grid-intrinsic-track-sizes-001.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Grid Layout Test: Intrinsic contribution of a small item to intrinsic tracks</title>
<link rel="author" title="Elika J. Etemad" href="http://fantasai.inkedblade.net/contact">
<link rel="help" href="https://www.w3.org/TR/css-grid-1/#algo-content">
<meta name="assert" content="This test checks that the intrinsic contribution of a single grid item smaller than its container is distributed correctly among the tracks it spans when intrinsic tracks are involved.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
#grid {
display: grid;
width: 120px;
height: 120px;
border: solid;
font: 10px/1 Ahem;
}
#item {
background: blue;
/* make min-content contribution differ from minimum contribution */
min-width: 12px;
min-height: 12px;
}
</style>
<div id="grid">
<div id="item">XXX XX<br>XX<br>XX</div>
</div>
<div id="log"></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../grid-definition/support/testing-utils.js"></script>
<script>
const item = document.getElementById("item");
function checkTrackSizes(span, trackList, expectedCols, expectedRows) {
item.style.gridColumn = item.style.gridRow = `span ${span}`;
if (!expectedRows) {
expectedRows = expectedCols;
}
TestingUtils.testGridTemplateColumnsRows("grid", trackList, trackList, expectedCols, expectedRows);
}
setup({ explicit_done: true });
document.fonts.ready.then(() => {
// Item spanning a single track
checkTrackSizes(1, "auto", "120px");
checkTrackSizes(1, "min-content", "30px", "40px");
checkTrackSizes(1, "max-content", "60px", "30px");
checkTrackSizes(1, "minmax(0, auto)", "120px");
checkTrackSizes(1, "minmax(0, min-content)", "30px", "40px");
checkTrackSizes(1, "minmax(0, max-content)", "60px", "30px");
checkTrackSizes(1, "minmax(auto, 10px)", "12px");
checkTrackSizes(1, "minmax(min-content, 10px)", "30px", "40px");
checkTrackSizes(1, "minmax(max-content, 10px)", "60px", "30px");
// Item spanning two identical tracks
checkTrackSizes(2, "auto auto", "60px 60px");
checkTrackSizes(2, "min-content min-content", "15px 15px", "20px 20px");
checkTrackSizes(2, "max-content max-content", "30px 30px", "15px 15px");
checkTrackSizes(2, "minmax(0, auto) minmax(0, auto)", "60px 60px");
checkTrackSizes(2, "minmax(0, min-content) minmax(0, min-content)", "15px 15px", "20px 20px");
checkTrackSizes(2, "minmax(0, max-content) minmax(0, max-content)", "30px 30px", "15px 15px");
checkTrackSizes(2, "minmax(auto, 4px) minmax(auto, 4px)", "6px 6px");
checkTrackSizes(2, "minmax(auto, 10px) minmax(auto, 10px)", "10px 10px");
checkTrackSizes(2, "minmax(min-content, 10px) minmax(min-content, 10px)", "15px 15px", "20px 20px");
checkTrackSizes(2, "minmax(max-content, 10px) minmax(max-content, 10px)", "30px 30px", "15px 15px");
// Item spanning a fixed track also
checkTrackSizes(2, "20px auto", "20px 100px");
checkTrackSizes(2, "20px min-content", "20px 10px", "20px 20px");
checkTrackSizes(2, "20px max-content", "20px 40px", "20px 10px");
checkTrackSizes(2, "20px minmax(0, auto)", "20px 100px");
checkTrackSizes(2, "20px minmax(0, min-content)", "20px 10px", "20px 20px");
checkTrackSizes(2, "20px minmax(0, max-content)", "20px 40px", "20px 10px");
checkTrackSizes(2, "20px minmax(auto, 30px)", "20px 30px");
checkTrackSizes(2, "20px minmax(min-content, 6px)", "20px 10px", "20px 20px");
checkTrackSizes(2, "20px minmax(min-content, 40px)", "20px 40px", "20px 40px");
checkTrackSizes(2, "20px minmax(max-content, 6px)", "20px 40px", "20px 10px");
checkTrackSizes(2, "20px minmax(max-content, 30px)", "20px 40px", "20px 30px");
// Item spanning two mismatched intrinsic tracks
checkTrackSizes(2, "max-content min-content", "45px 15px", "15px 15px");
done();
});
</script>