Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-anchor-position/anchor-center-safe.html - WPT Dashboard Interop Dashboard
<!doctype html>
<title>Tests whether safe alignment works correctly on the anchor element.</title>
<link rel="match" href="anchor-center-safe-ref.html">
<style>
.anchor {
position: fixed;
left: 0px;
top: 0px;
height: 30px;
color: white;
background-color: green;
anchor-name: --myAnchor;
}
.infobox {
color: darkblue;
background-color: azure;
border: 1px solid #ddd;
padding: 10px;
position: fixed;
position-anchor: --myAnchor;
top: calc(anchor(bottom) + 5px);
left: 0px;
justify-self: safe anchor-center;
}
.anchor2 {
position: fixed;
top: 0px;
left: 340px;
height: 30px;
width: 100px;
color: white;
background-color: green;
anchor-name: --myAnchor2;
}
.infobox2 {
color: darkblue;
background-color: azure;
border: 1px solid #ddd;
padding: 10px;
position: fixed;
position-anchor: --myAnchor2;
left: calc(anchor(right) + 5px);
align-self: safe anchor-center;
}
</style>
<div class="anchor">Anchor</div>
<div class="infobox">
<p>Anchored element with justify-self</p>
</div>
<div class="anchor2">Anchor2</div>
<div class="infobox2">
<p>Anchored element with align-self</p>
</div>