mirror of
https://github.com/servo/servo.git
synced 2025-07-22 06:43:40 +01:00
103 lines
2.4 KiB
HTML
103 lines
2.4 KiB
HTML
<!DOCTYPE html>
|
|
<title>position:sticky elements should respect the left constraint</title>
|
|
<link rel="match" href="position-sticky-left-ref.html" />
|
|
<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos" />
|
|
<meta name="assert" content="This test checks that position:sticky elements obey their left anchor after scrolling" />
|
|
|
|
<style>
|
|
.group {
|
|
position: relative;
|
|
width: 250px;
|
|
height: 150px;
|
|
}
|
|
|
|
.scroller {
|
|
position: relative;
|
|
width: 200px;
|
|
height: 100px;
|
|
overflow-x: auto;
|
|
overflow-y: hidden;
|
|
}
|
|
|
|
.contents {
|
|
height: 100%;
|
|
width: 500px;
|
|
}
|
|
|
|
.prepadding {
|
|
display: inline-block;
|
|
height: 100%;
|
|
width: 100px;
|
|
}
|
|
|
|
.container {
|
|
display: inline-block;
|
|
height: 100%;
|
|
width: 200px;
|
|
}
|
|
|
|
.innerpadding {
|
|
display: inline-block;
|
|
height: 100%;
|
|
width: 50px;
|
|
}
|
|
|
|
.indicator {
|
|
background-color: red;
|
|
position: absolute;
|
|
top: 0;
|
|
}
|
|
|
|
.sticky {
|
|
background-color: green;
|
|
position: sticky;
|
|
left: 50px;
|
|
}
|
|
|
|
.box {
|
|
display: inline-block;
|
|
height: 100%;
|
|
width: 100px;
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
|
window.addEventListener('load', function() {
|
|
document.getElementById('scroller1').scrollLeft = 50;
|
|
document.getElementById('scroller2').scrollLeft = 125;
|
|
document.getElementById('scroller3').scrollLeft = 200;
|
|
});
|
|
</script>
|
|
|
|
<div class="group">
|
|
<div id="scroller1" class="scroller">
|
|
<div class="indicator box" style="left: 150px;"></div>
|
|
<div class="contents">
|
|
<!-- As these elements are inline, they are whitespace sensitive. -->
|
|
<div class="prepadding"></div><div class="container"><div class="innerpadding"></div><div class="sticky box"></div></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="group">
|
|
<div id="scroller2" class="scroller">
|
|
<div class="indicator box" style="left: 175px;"></div>
|
|
<div class="contents">
|
|
<!-- As these elements are inline, they are whitespace sensitive. -->
|
|
<div class="prepadding"></div><div class="container"><div class="innerpadding"></div><div class="sticky box"></div></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="group">
|
|
<div id="scroller3" class="scroller">
|
|
<div class="indicator box" style="left: 200px;"></div>
|
|
<div class="contents">
|
|
<!-- As these elements are inline, they are whitespace sensitive. -->
|
|
<div class="prepadding"></div><div class="container"><div class="innerpadding"></div><div class="sticky box"></div></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div>You should see three green boxes above. No red should be visible.</div>
|