summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-grid/grid-items/grid-items-percentage-margins-001.html
blob: dc1602ab173a604a9266890425bb1bd2e9620e75 (plain)
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
94
95
96
97
98
99
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Grid Layout Test: Grid items with percentage margins</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-grid-1/#item-margins">
<meta name="assert" content="Checks grid items percentage margins are resolved against the inline size of their grid area (in a fixed size track).">
<link rel="stylesheet" href="/css/support/grid.css">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
.grid {
  font: 10px/1 Ahem;
  grid-template-columns: 100px;
  width: 500px;
  justify-items: start;
  position: relative;
}

.grid > div:nth-child(1) { background: cyan; }
.grid > div:nth-child(2) {
  background: magenta;
  width: 100%;
  height: 10px;
}

.marginLeft50Percent { margin-left: 50%; }
.marginRight50Percent { margin-right: 50%; }
.marginTop50Percent { margin-top: 50%; }
.marginBottom50Percent { margin-bottom: 50%; }
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
  setup({ explicit_done: true });
</script>

<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div id="log"></div>

<h3>Direction LTR</h3>

<pre>Item margin-left: 50%;</pre>

<div class="grid">
  <div class="marginLeft50Percent" data-expected-margin-left="50" data-offset-x="50" data-expected-width="10" data-expected-height="10">X</div>
  <div data-offset-x="0" data-offset-y="10" data-expected-width="100" data-expected-height="10"></div>
</div>

<pre>Item margin-right: 50%;</pre>

<div class="grid">
  <div class="marginRight50Percent" data-expected-margin-right="50" data-offset-x="0" data-expected-width="10" data-expected-height="10">X</div>
  <div data-offset-x="0" data-offset-y="10" data-expected-width="100" data-expected-height="10"></div>
</div>

<pre>Item margin-top: 50%;</pre>

<div class="grid">
  <div class="marginTop50Percent" data-expected-margin-top="50" data-offset-y="50" data-expected-width="10" data-expected-height="10">X</div>
  <div data-offset-x="0" data-offset-y="60" data-expected-width="100" data-expected-height="10"></div>
</div>

<pre>Item margin-bottom: 50%;</pre>

<div class="grid">
  <div class="marginBottom50Percent" data-expected-margin-bottom="50" data-offset-y="0" data-expected-width="10" data-expected-height="10">X</div>
  <div data-offset-x="0" data-offset-y="60" data-expected-width="100" data-expected-height="10"></div>
</div>

<h3>Direction RTL</h3>

<pre>Item margin-left: 50%;</pre>

<div class="grid directionRTL">
  <div class="marginLeft50Percent" data-expected-margin-left="50" data-offset-x="490" data-expected-width="10" data-expected-height="10">X</div>
  <div data-offset-x="400" data-offset-y="10" data-expected-width="100" data-expected-height="10"></div>
</div>

<pre>Item margin-right: 50%;</pre>

<div class="grid directionRTL">
  <div class="marginRight50Percent" data-expected-margin-right="50" data-offset-x="440" data-expected-width="10" data-expected-height="10">X</div>
  <div data-offset-x="400" data-offset-y="10" data-expected-width="100" data-expected-height="10"></div>
</div>

<pre>Item margin-top: 50%;</pre>

<div class="grid directionRTL">
  <div class="marginTop50Percent" data-expected-margin-top="50" data-offset-y="50" data-expected-width="10" data-expected-height="10">X</div>
  <div data-offset-x="400" data-offset-y="60" data-expected-width="100" data-expected-height="10"></div>
</div>

<pre>Item margin-bottom: 50%;</pre>

<div class="grid directionRTL">
  <div class="marginBottom50Percent" data-expected-margin-bottom="50" data-offset-y="0" data-expected-width="10" data-expected-height="10">X</div>
  <div data-offset-x="400" data-offset-y="60" data-expected-width="100" data-expected-height="10"></div>
</div>