Skip to content

Commit 41b3cf2

Browse files
committed
1 parent d33e83d commit 41b3cf2

3 files changed

Lines changed: 66 additions & 2 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!DOCTYPE html>
2+
<html id=root>
3+
<title>CSS Anchor Positioning: position-area vs initial containing block</title>
4+
<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#position-area">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<style>
8+
:root {
9+
margin: 10px 20px;
10+
border: 2px solid;
11+
overflow: hidden;
12+
}
13+
#anchored {
14+
position: fixed;
15+
inset: 0;
16+
border: solid orange;
17+
}
18+
#sizer {
19+
position: absolute;
20+
inset: 0;
21+
height: 100vh;
22+
width: 100vw;
23+
}
24+
25+
</style>
26+
<div id="sizer"></div>
27+
<div id="container">
28+
<div id="anchored"></div>
29+
</div>
30+
<script>
31+
function check(title, expected_offsets) {
32+
test(() => {
33+
assert_equals(anchored.offsetLeft, expected_offsets.left, "Check expected offsetLeft");
34+
assert_equals(anchored.offsetTop, expected_offsets.top, "Check expected offsetTop");
35+
assert_equals(anchored.offsetWidth, expected_offsets.width, "Check expected offsetWidth");
36+
assert_equals(anchored.offsetHeight, expected_offsets.height, "Check expected offsetHeight");
37+
}, "Offsets for: " + title);
38+
}
39+
40+
vh = sizer.offsetHeight;
41+
vw = sizer.offsetWidth;
42+
43+
check("position-area: none for basic ICB", {left:0, top:0, width:vw, height:vh});
44+
45+
anchored.positionArea = "span-all";
46+
check("position-area: span-all for basic ICB", {left:0, top:0, width:vw, height:vh});
47+
48+
sizer.style.width = "200vw";
49+
sizer.style.height = "200vh";
50+
check("position-area: span-all for abspos overflowing ICB", {left:0, top:0, width:vw, height:vh});
51+
52+
sizer.style.position = "static";
53+
check("position-area: span-all for in-flow overflowing ICB", {left:0, top:0, width:vw, height: vh});
54+
55+
root.style.width = "200vw";
56+
check("position-area: span-all for root overflowing ICB", {left:0, top:0, width: vw, height: vh});
57+
58+
root.style.width = "50%";
59+
root.style.height = "50%";
60+
check("position-area: span-all for abspos overflowing ICB and reduced root", {left:0, top:0, width:vw, height:vh});
61+
62+
anchored.style.positionArea = "none";
63+
check("position-area: none for in-flow overflowing ICB and reduced root", {left:0, top:0, width:vw, height:vh});
64+
</script>

css/css-anchor-position/position-area-overflow-icb-001.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<html dir=rtl>
3-
<title>position-area overflow alignment against ICB - non-scrollable RTL</title>
3+
<title>position-area overflow alignment against ICB - non-overflowing RTL root</title>
44
<link rel="help" href="https://www.w3.org/TR/css-anchor-position/#position-area">
55
<link rel="help" href="https://www.w3.org/TR/css-align-3/#auto-safety-position">
66
<meta name=assert content="Test passes if the positioned box is aligned as specified to the extent possible within the scrollable area.">

css/css-anchor-position/position-area-overflow-icb-002.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<html dir=rtl>
3-
<title>position-area overflow alignment against ICB - scrollable RTL</title>
3+
<title>position-area overflow alignment against ICB - scrollable RTL root</title>
44
<link rel="help" href="https://www.w3.org/TR/css-anchor-position/#position-area">
55
<link rel="help" href="https://www.w3.org/TR/css-align-3/#auto-safety-position">
66
<meta name=assert content="Test passes if the positioned box is aligned as specified to the extent possible within the scrollable area.">

0 commit comments

Comments
 (0)