79 lines
2.3 KiB
HTML
79 lines
2.3 KiB
HTML
<!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);
|
|
order: 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: "";
|
|
display: list-item;
|
|
z-index: calc(sibling-index() * 2);
|
|
order: calc(sibling-count() * 2);
|
|
}
|
|
#test::before::marker {
|
|
font-weight: calc(sibling-index() * 2);
|
|
font-size: calc(sibling-count() * 2px);
|
|
}
|
|
</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.order, '10');
|
|
}, 'sibling-index() and sibling-count() on pseudo-element');
|
|
|
|
test(() => {
|
|
// Requires nested pseudo-element selectors: https://github.com/w3c/csswg-drafts/issues/4456
|
|
let style = getComputedStyle(document.getElementById('test'), '::before::marker');
|
|
assert_equals(style.fontWeight, '4');
|
|
assert_equals(style.fontSize, '10px');
|
|
}, 'sibling-index() and sibling-count() on nested 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.order, '2');
|
|
}, 'sibling-count() on root');
|
|
</script>
|
|
</body>
|
|
</html>
|