summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/position-fallback-004.html
blob: e4dbd718664fca1d5aa1276b32a8c6e94f907c3a (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
<!DOCTYPE html>
<title>Tests margin properties in position fallback</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#accepted-try-properties">
<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>
body {
  margin: 0;
}

.cb {
  width: 300px;
  height: 150px;
  position: relative;
  background: lightgray;
}

.anchor {
  position: absolute;
  width: 100px;
  height: 100px;
  top: 25px;
  background: orange;
  anchor-name: --a;
}

.target {
  position: absolute;
  width: 100px;
  height: 100px;
  background: lime;
  position-fallback: --fallbacks;
}

@position-fallback --fallbacks {
  @try {
    top: anchor(--a top);
    right: anchor(--a left);
    margin-top: 10px;
    margin-right: 10px;
  }

  @try {
    bottom: anchor(--a bottom);
    left: anchor(--a right);
    margin-bottom: 10px;
    margin-left: 10px;
  }
}
</style>

<body onload="checkLayoutForAnchorPos('.target')">

<div class=cb>
  <div class=anchor style="left: 110px"></div>
  <!-- Chooses 1st @try block. -->
  <div class=target data-offset-x=0
       data-expected-margin-left=0 data-expected-margin-right=10
       data-expected-margin-top=10 data-expected-margin-bottom=0></div>
</div>

<div class=cb>
  <div class=anchor style="right: 110px"></div>
  <!-- Chooses 2nd @try block. -->
  <div class=target data-offset-x=200
       data-expected-margin-left=10 data-expected-margin-right=0
       data-expected-margin-top=0 data-expected-margin-bottom=10></div>
</div>

</body>