Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Anchor Positioning Test: anchor() against an anchor in an inline box containing block in a multicol container</title>
<meta name="assert" content="anchor() resolves against the anchor box when the anchor box is absolutely positioned, with and without insets, in a relatively positioned inline box in the second column of a multicol container.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="stylesheet" href="/fonts/ahem.css">
<style>
.container { position: relative; }
.multicol { columns: 2; column-gap: 0; column-fill: auto; width: 400px; height: 100px; font: 20px/1 Ahem; }
.anchor { position: absolute; width: 10px; height: 10px; }
.insets { top: 5px; left: 7px; }
.anchored { position: absolute; left: anchor(right); top: anchor(bottom); width: 5px; height: 5px; }
</style>
<div class="container">
<div class="multicol">XX<br>XX<br>XX<br>XX<br>XX<br>XX<br>XX <span style="position: relative; padding-left: 3px">XX<div class="anchor insets" style="anchor-name: --with-insets"></div></span></div>
<div class="anchored" style="position-anchor: --with-insets"></div>
</div>
<div class="container">
<div class="multicol">XX<br>XX<br>XX<br>XX<br>XX<br>XX<br>XX <span style="position: relative; padding-left: 3px">XX<span class="anchor" style="anchor-name: --without-insets"></span></span></div>
<div class="anchored" style="position-anchor: --without-insets"></div>
</div>
<script>
for (const container of document.querySelectorAll(".container")) {
test(() => {
const anchor = container.querySelector(".anchor").getBoundingClientRect();
const anchored = container.querySelector(".anchored").getBoundingClientRect();
assert_approx_equals(anchored.left, anchor.right, 0.5, "left");
assert_approx_equals(anchored.top, anchor.bottom, 0.5, "top");
}, `anchor() resolves against an anchor ${container.querySelector(".insets") ? "with" : "without"} insets in an inline box containing block in the second column`);
}
</script>