blob: 7735115e592dca0168cc3ac41e6762534de9bfa9 (
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
75
76
77
78
79
80
81
82
|
<!DOCTYPE html>
<title>Tests basic functionalities of 'position-fallback-bounds'</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#fallback-bounds">
<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;
}
.container {
position: relative;
width: 400px;
height: 400px;
top: 100px;
anchor-name: --bounds;
outline: 1px dashed black;
}
.anchor {
position: absolute;
width: 100px;
height: 100px;
left: 150px;
background-color: orange;
}
.target {
position: fixed;
width: 100px;
height: 100px;
background-color: lime;
left: anchor(left);
position-fallback-bounds: --bounds;
}
#anchor1 {
top: 0;
anchor-name: --a1;
}
#anchor2 {
bottom: 0;
anchor-name: --a2;
}
#target1 {
anchor-default: --a1;
position-fallback: --top-then-bottom;
}
#target2 {
anchor-default: --a2;
position-fallback: --bottom-then-top;
}
@position-fallback --top-then-bottom {
@try { bottom: anchor(top); }
@try { top: anchor(bottom); }
}
@position-fallback --bottom-then-top {
@try { top: anchor(bottom); }
@try { bottom: anchor(top); }
}
</style>
<body onload="checkLayoutForAnchorPos('.target')">
<div class="container" id="bounds">
<div class="anchor" id="anchor1"></div>
<div class="anchor" id="anchor2"></div>
</div>
<!-- Enough space above the anchor in the viewport but not in the additional
bounds rect, which triggers fallback -->
<div class="target" id="target1" data-offset-y=200></div>
<!-- Enough space below the anchor in the viewport but not in the additional
bounds rect, which triggers fallback -->
<div class="target" id="target2" data-offset-y=300></div>
</body>
|