summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/anchor-position-003.html
blob: c149dd0e110e6486ed3aa9c453fd9f74efcee38e (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
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#determining">
<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;
}
.not-positioned-cb {
  transform: translate(0, 0);  /* Make it a containing block. */
}
.anchor1 {
  anchor-name: --a1;
}
.size5x7 {
  width: 5px;
  height: 7px;
  background: orange;
}
.size9x11 {
  width: 9px;
  height: 11px;
  background: blue;
}
.target {
  position: absolute;
}
</style>
<!--
  To determine the target anchor element, find the last acceptable anchor
  element el in tree order.
  https://drafts.csswg.org/css-anchor-1/#determining
-->
<body onload="checkLayoutForAnchorPos('.target')">
  <div class="cb">
    <div class="anchor1 size5x7"></div>
    <div class="anchor1 size9x11"></div>
    <div class="target" style="left: anchor(--a1 right)" data-offset-x=9></div>
  </div>

  <div class="cb">
    <div class="anchor1 size5x7">
      <div class="anchor1 size9x11"></div>
      <div class="target" style="left: anchor(--a1 right)" data-offset-x=9></div>
    </div>
    <div class="target" style="left: anchor(--a1 right)" data-offset-x=9></div>
  </div>

  <div class="cb">
    <div class="anchor1 size5x7 not-positioned-cb">
      <div class="anchor1 size9x11"></div>
      <div class="target" style="left: anchor(--a1 right)" data-offset-x=9></div>
    </div>
    <div class="target" style="left: anchor(--a1 right)" data-offset-x=9></div>
  </div>
</body>