blob: ca709af3de112869c60db378175fbdd5f2c7a06f (
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>Variable substitution in @try rules</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<style>
.cb {
position: relative;
width: 195px;
height: 70px;
background: yellow;
border-bottom: 1px solid black;
}
.spacer {
width: 1px;
height: 20px;
}
.anchor1 {
anchor-name: --a1;
margin-left: 45px;
width: 100px;
height: 30px;
background: blue;
}
.target {
position: absolute;
position-fallback: --fallback1;
width: 40px;
height: 15px;
margin: 5px;
background: orange;
--left: anchor(--a1 right);
--top: anchor(--a1 top);
}
.fallback1 {
position-fallback: --fallback1;
}
.fallback2 {
position-fallback: --fallback2;
}
@position-fallback --fallback1 {
@try { /* Position to the right of the anchor. */
left: var(--left);
top: var(--top);
}
}
/* Same as above, but using a shorthand. */
@position-fallback --fallback2 {
@try {
inset: var(--top) 0px 0px var(--left);
}
}
</style>
<body onload="checkLayout('.target')">
<div class="cb">
<div class="spacer"></div>
<div class="anchor1"></div>
<div class="target fallback1"
data-offset-x=150 data-offset-y=25></div>
</div>
<div class="cb">
<div class="spacer"></div>
<div class="anchor1"></div>
<div class="target fallback2"
data-offset-x=150 data-offset-y=25></div>
</div>
</body>
|