wpt / css / css-anchor-position / position-area-scroll-adjust.html

Status: PASS | Duration: 7ms | Subtests: 1/1 | Open test on wpt.live | Open ref on wpt.live | wpt.fyi

/css/css-anchor-position/position-area-scroll-adjust.html

<!DOCTYPE html>
<title>CSS Anchor Positioning: position-area anchored against scrolling anchor</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#position-area">
<link rel="match" href="position-area-scroll-adjust-ref.html">
<style>
  #scroller {
    width: 400px;
    height: 200px;
    overflow: auto;
  }
  #anchor {
    anchor-name: --a;
    background: green;
    width: 200px;
    height: 100px;
  }
  #anchored {
    position-anchor: --a;
    position-area: bottom;
    margin: 0;
    padding: 0;
    border: none;
    background: green;
    width: 200px;
    height: 100px;
  }
  .filler { height: 200px; }
</style>
<p>You should see a green square below</p>
<div id="scroller">
  <div class="filler"></div>
  <div id="anchor" popovertarget="anchored"></div>
  <div id="anchored" popover></div>
  <div class="filler"></div>
  <div class="filler"></div>
</div>
<script>
  anchored.showPopover();
  scroller.scrollTop = 200;
</script>

/css/css-anchor-position/position-area-scroll-adjust-ref.html

<!DOCTYPE html>
<title>CSS Test Reference</title>
<p>You should see a green square below</p>
<div id="scroller" style="overflow:auto;width:400px;height:200px">
  <div style="height:200px"></div>
  <div style="width:200px;height:200px;background:green"></div>
  <div style="height:300px"></div>
</div>
<script>
  scroller.scrollTop = 200;
</script>