summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/anchor-position-dynamic-001.html
blob: 96d5f996ef363efef7f32d206e37a25db6569929 (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
<!DOCTYPE html>
<title>Tests `anchor` function when anchor positions are changed dynamically</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#propdef-anchor-name">
<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>
#container {
  position: relative;
}
#a1 {
  anchor-name: --a1;
  background: orange;
  margin-left: 100px;
  margin-top: 100px;
  width: 50px;
  height: 50px;
}
.after #a1 {
  width: 100px;
  height: 100px;
}
#a2 {
  anchor-name: --a2;
  background: purple;
  margin-left: 250px;
  margin-top: 350px;
  width: 100px;
  height: 100px;
}
.after #a2 {
  margin-left: 500px;
  margin-top: 100px;
}
#target {
  background: green;
  position: absolute;
  left: anchor(--a1 right);
  top: anchor(--a1 bottom);
  right: anchor(--a2 left);
  bottom: anchor(--a2 top);
}
#ref {
  background: red;
  position: absolute;
  left: 200px;
  top: 100px;
  width: 300px;
  height: 100px;
}
</style>
<body>
  <div id="container">
    <div id="a1"></div>
    <div id="a2"></div>
    <div id="ref"></div>
    <div id="target"
        data-offset-x=200 data-offset-y=100
        data-expected-width=300 data-expected-height=100></div>
  </div>
<script type="module">
document.body.offsetTop;  // Force layout.
container.classList.add('after');
await checkLayoutForAnchorPos('#target');
</script>
</body>