Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>CSS Anchor Positioning: element is visible after position-anchor is dynamically unset</title>
<link rel="author" title="Peng Zhou" href="mailto:zhoupeng.1996@bytedance.com">
<link rel="match" href="position-anchor-dynamic-unset-visibility-hidden-ref.html">
<style>
#anchor {
position: fixed;
left: 50px;
top: 50px;
width: 50px;
height: 50px;
anchor-name: --a1;
visibility: hidden;
}
#popover {
position: fixed;
left: anchor(left, 100px);
top: anchor(bottom, 100px);
width: 50px;
height: 50px;
background: green;
}
</style>
<div id="anchor"></div>
<div id="popover"></div>
<script>
popover.style.positionAnchor = '--a1';
let forceLayout = popover.offsetWidth;
popover.style.positionAnchor = '';
</script>
</html>