summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/position-try-002.html
blob: c3d550adb1ee4f2e111f37baa643fbbe0724ca4a (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
<!DOCTYPE html>
<title>Tests that overflowing the inset-modified containing block triggers position fallback</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback">
<link rel="author" href="mailto:xiaochengh@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 {
  width: 400px;
  height: 400px;
  transform: scale(1);
  background: yellow;
}
.anchor1 {
  anchor-name: --a;
  margin-left: 100px;
  width: 100px;
  height: 100px;
  background: blue;
}
.target {
  position: absolute;
  position-try-options: --f1, --f2;
  width: min-content;
  height: 100px;
  background: orange;
  /* 1: Position to the left of the anchor. */
  left: 0;
  right: anchor(--a left);
  top: anchor(--a top);
}
.inline-spacer {
  display: inline-block;
  width: 200px;
  height: 100px;
}
@position-try --f1 {
  /* 2: Position to the right of the anchor. */
  left: anchor(--a right);
  right: 0;
  top: anchor(--a top);
}
@position-try --f2 {
  /* 3: Placeholder fallback that shouldn't be selected when the previous
        ones do not overflow the available space. */
  inset: 0;
}
</style>
<body onload="checkLayoutForAnchorPos('.target')">
  <!-- The first base style overflows the inset-modifed containing block -->
  <div class="cb">
    <div class="anchor1"></div>
    <div class="target"
         data-offset-x=200 data-offset-y=0
         data-expected-width=200 data-expected-height=100>
      <span class="inline-spacer"></span>
    </div>
  </div>
</body>