summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/anchor-position-grid-001.html
blob: 92fb4d275b8988641ed0736969e918703e4d649d (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
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#anchor-pos">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#anchor-size">
<link rel="author" href="mailto:kojii@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script src="support/test-common.js"></script>
<style>
.cb {
  position: relative;
}
.columns {
  column-count: 3;
  column-fill: auto;
  column-gap: 10px;
  width: 620px;
  height: 100px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, 100px);
  grid-template-rows: 50px 100px;
}
.spacer {
  background: yellow;
}
.anchor1 {
  anchor-name: --a1;
  grid-column: 2;
  grid-row: 2;
  border: 2px solid orange;
  border-width: 5px 6px 7px 8px;
}
.target {
  grid-column: 2;
  grid-row: 2;
  position: absolute;
  width: anchor-size(--a1 width);
  height: anchor-size(--a1 height);
  background: lime;
  opacity: .2;
}
.target1-l {
  left: anchor(--a1 left);
  top: anchor(--a1 top);
  width: 8px;
}
.target1-r {
  right: anchor(--a1 right);
  bottom: anchor(--a1 bottom);
  width: 6px;
}
.target1-t {
  left: anchor(--a1 left);
  top: anchor(--a1 top);
  height: 5px;
}
.target1-b {
  right: anchor(--a1 right);
  bottom: anchor(--a1 bottom);
  height: 5px;
}
</style>
<body onload="checkLayoutForAnchorPos('.target')">
  <div>
    <div class="spacer" style="height: 10px"></div>
    <div class="columns">
      <div class="spacer" style="height: 10px"></div>
      <div class="grid cb">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div class="anchor1"></div>

        <div class="target target1-l" data-offset-x=100 data-expected-height=100></div>
        <div class="target target1-r" data-offset-x=404 data-expected-height=100></div>
        <div class="target target1-t" data-offset-y=0 data-expected-width=310></div>
        <div class="target target1-b" data-offset-y=95 data-expected-width=310></div>
      </div>
    </div>
  </div>
</body>