blob: 0f84311d6d784fdb33fd2c6642a838deefb60830 (
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
|
<!DOCTYPE html>
<title>Tests that anchor functions inherit as pixels</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script src="/css/css-anchor-position/support/test-common.js"></script>
<style>
.cb {
width: 400px;
height: 400px;
position: relative;
border: 1px solid black;
}
.anchor {
width: 100px;
height: 100px;
top: 10px;
left: 20px;
position: absolute;
background: red;
anchor-name: --a;
}
.anchored {
position-anchor: --a;
position: absolute;
/* Anchored directly on top */
top: anchor(top);
left: anchor(left);
width: anchor-size(width);
height: anchor-size(height);
background: coral;
}
/* The child should have the same size as the anchored element,
and inset by top:10px,left:20px vs. that element. */
.child {
position-anchor: --unknown; /* Should have no effect. */
position: relative;
background: skyblue;
top: inherit;
left: inherit;
width: inherit;
height: inherit;
}
</style>
<body onload="checkLayoutForAnchorPos('.child')">
<div class=cb>
<div class=anchor></div>
<div class=anchored>
<div class=child
data-offset-x=20 data-offset-y=10
data-expected-width=100 data-expected-height=100></div>
</div>
</div>
</body>
|