Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-anchor-position/position-try-position-anchor.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>CSS Anchor Positioning Test: @position-try can set position-anchor</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script src="support/test-common.js"></script>
<style>
#cb {
position: relative;
width: 400px;
height: 400px;
}
.anchor {
width: 100px;
height: 100px;
}
#anchor-a {
anchor-name: --a;
/* Makes #anchored overflow when aligned with right edge */
margin-left: 100px;
}
#anchor-b {
anchor-name: --b;
}
#anchored {
position: absolute;
left: anchor(right);
width: 300px;
height: 100px;
position-anchor: --a;
position-try-fallbacks: --pf;
}
@position-try --pf {
position-anchor: --b;
}
</style>
<body onload="checkLayoutForAnchorPos('#anchored')">
<div id="cb">
<div id="anchor-a" class="anchor"></div>
<div id="anchor-b" class="anchor"></div>
<div id="anchored" data-offset-x="100"></div>
</div>