-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathcalc-sibling-function.html
More file actions
66 lines (61 loc) · 1.77 KB
/
calc-sibling-function.html
File metadata and controls
66 lines (61 loc) · 1.77 KB
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
<!DOCTYPE HTML>
<html>
<head>
<title>CSS sibling-index() and sibling-count()</title>
<link rel="help" href="https://drafts.csswg.org/css-values-5/#tree-counting" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
html {
z-index: calc(sibling-index() * 2);
widows: calc(sibling-count() * 2);
}
#test {
z-index: calc(sibling-index());
counter-increment: foo calc(sibling-count());
left: calc(10% + 100px * sibling-index());
}
#test::before {
content: "";
z-index: calc(sibling-index() * 2);
widows: calc(sibling-count() * 2);
}
</style>
</head>
<body>
<div>
<div></div>
<div id="test"></div>
<div></div>
<div></div>
<ul></ul>
</div>
<script>
test(() => {
let style = getComputedStyle(document.getElementById('test'));
assert_equals(style.zIndex, '2');
}, 'basic sibling-index() test');
test(() => {
let style = getComputedStyle(document.getElementById('test'));
assert_equals(style.counterIncrement, 'foo 5');
}, 'basic sibling-count() test');
test(() => {
let style = getComputedStyle(document.getElementById('test'));
assert_equals(style.left, 'calc(10% + 200px)');
}, 'sibling-index() in calc() with percentage');
test(() => {
let style = getComputedStyle(document.getElementById('test'), '::before');
assert_equals(style.zIndex, '4');
assert_equals(style.widows, '10');
}, 'sibling-count() on pseudo-element');
test(() => {
let style = getComputedStyle(document.documentElement);
assert_equals(style.zIndex, '2');
}, 'sibling-index() on root');
test(() => {
let style = getComputedStyle(document.documentElement);
assert_equals(style.widows, '2');
}, 'sibling-count() on root');
</script>
</body>
</html>