<!DOCTYPE html>
<title>Reference for position:sticky elements should work correctly with grid layout</title>
<style>
.scroller {
position: relative;
overflow-x: scroll;
overflow-y: hidden;
width: 300px;
height: 100px;
margin-bottom: 15px;
}
.grid-container {
display: grid;
grid-template-columns: 25% 25% 25% 25%;
grid-template-rows: 100%;
width: 400px;
height: 90px;
}
.green {
background-color: green;
}
.grid-item {
width: 100%;
height: 100%;
grid-row: 1;
}
.padding {
height: 1px;
width: 700px;
}
</style>
<script>
window.addEventListener('load', function() {
document.getElementById('scroller1').scrollLeft = 0;
document.getElementById('scroller2').scrollLeft = 150;
document.getElementById('scroller3').scrollLeft = 300;
});
</script>
<p>You should see three green boxes of varying size below. There should be no red or blue.</p>
<div id="scroller1" class="scroller">
<div class="grid-container">
<div class="grid-item" style="grid-column: 1;"></div>
<div class="green grid-item" style="grid-column: 2;"></div>
<div class="green grid-item" style="grid-column: 3;"></div>
</div>
<div class="padding"></div>
</div>
<div id="scroller2" class="scroller">
<div class="grid-container">
<div class="grid-item" style="grid-column: 1;"></div>
<div class="grid-item" style="grid-column: 2;"></div>
<div class="green grid-item" style="grid-column: 3;"></div>
</div>
<div class="padding"></div>
</div>
<div id="scroller3" class="scroller">
<div class="grid-container">
<div class="grid-item" style="grid-column: 1;"></div>
<div class="grid-item" style="grid-column: 2;"></div>
<div class="grid-item" style="grid-column: 3;"></div>
<div class="green grid-item" style="grid-column: 4;"></div>
</div>
<div class="padding"></div>
</div>