Skip to content
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CSS Anchor Positioning Polyfill Demo</title>
<link type="text/css" href="/demo.css" />
<link rel="stylesheet" href="/parsing-test.css" />
<!-- <link type="text/css" href="/demo.css" />
<link rel="stylesheet" href="/anchor.css" />
<link
rel="stylesheet"
data-style-anchor-positioning
href="/anchor-positioning.css"
/>
<link rel="stylesheet" href="/position-fallback.css" />
<link rel="stylesheet" href="/anchor-with-position-fallback.css" />
<link rel="stylesheet" href="/anchor-scroll.css" />
<link rel="stylesheet" href="/anchor-size.css" />
<style>
Expand All @@ -32,7 +32,7 @@
left: anchor(--my-anchor-inline right);
background: green;
}
</style>
</style> -->
</head>
<body>
<h1>CSS Anchor Positioning Polyfill</h1>
Expand All @@ -50,7 +50,7 @@ <h2>Anchor Positioning via anchor() (stylesheet)</h2>
<div id="my-anchor-positioning">Anchor</div>
<div id="my-floating-positioning">Floating</div>
</div>

<!--
<h2>Anchor Positioning via anchor() (inline)</h2>
<div style="position: relative">
<div id="my-anchor-inline">Anchor</div>
Expand Down Expand Up @@ -84,7 +84,7 @@ <h2>Anchor() (used in math function)</h2>

<h2>Anchor Size</h2>
<div id="my-anchor-size">Anchor</div>
<div id="my-floating-size">Floating</div>
<div id="my-floating-size">Floating</div> -->

<script type="module">
import polyfill from '/src/index.ts';
Expand Down
2 changes: 1 addition & 1 deletion public/anchor-positioning.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
#my-floating-positioning {
position: absolute;
top: anchor(--my-anchor-positioning bottom);
left: anchor(--my-anchor-positioning right);
left: anchor(--my-anchor-positioning right, 50px);
background: green;
}
64 changes: 64 additions & 0 deletions public/parsing-test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#my-anchor-positioning {
anchor-name: --my-anchor-positioning;
background: orange;
margin-left: 100px;
margin-top: 100px;
width: 100px;
height: 100px;
}

.another {
anchor-name: --my-test-positioning;
}

.third {
anchor-name: --my-test-positioning;
}

#my-floating-positioning {
position: absolute;
top: anchor(--my-anchor-positioning bottom, 50px);
left: anchor(--my-anchor-positioning right);
bottom: anchor(--my-anchor-positioning top, calc(20% + 20px));
right: anchor(--nope top);
position-fallback: --fallback1;
width: 40px;
height: 15px;
margin: 5px;
background: green;
}

@position-fallback --fallback1 {
@try {
/* 1: Position to the right of the anchor. */
left: anchor(--my-anchor-positioning right);
top: anchor(--my-anchor-positioning top);
bottom: anchor(--nope top);
}

@try {
/* 2: Position to the left of the anchor. */
right: anchor(--my-anchor-positioning left);
top: anchor(--my-anchor-positioning top);
}

@try {
/* 3: Position to the bottom of the anchor. */
left: anchor(--my-anchor-positioning left);
top: anchor(--my-anchor-positioning bottom);
}

@try {
/* 4: Position to the top of the anchor. */
left: anchor(--my-anchor-positioning left);
bottom: anchor(--my-anchor-positioning top);
}

@try {
/* 5: Position to the left with the narrower width. */
left: anchor(--my-anchor-positioning right);
top: anchor(--my-anchor-positioning top);
width: 35px;
height: 40px;
}
}
Loading