summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/anchor-position-principal-box.html
blob: 9bb1fd4c4da814e3d621e5b65e0d3af3324333d7 (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
<!DOCTYPE html>
<title>anchor-name only applies to elements which generate a principal box</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#target-anchor-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
  body { margin-top: 0; }
  #outer {
    anchor-name: --anchor;
    display: contents;
  }
  #inner {
    anchor-name: --anchor;
  }
  #filler {
    height: 100px;
  }
  #anchored {
    position: absolute;
    top: anchor(--anchor top);
  }
</style>
<div id="outer">
  <div id="filler"></div>
  <div id="inner"></div>
</div>
<div id="anchored"></div>
<script>
  test(() => {
    assert_equals(anchored.offsetTop, 100, "#anchored is positioned against #inner");
  }, "anchor-name should only apply to elements which generate a principal box");
</script>