blob: c5b876a918d2b9ed7ec46e8030881fd851dd959e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0;
}
.group {
display: inline-block;
position: relative;
width: 180px;
height: 500px;
}
.container {
position: relative;
width: 150px;
height: 400px;
border: 2px solid black;
padding: 5px;
}
.box {
width: 120px;
height: 120px;
}
.sticky {
position: relative;
background-color: green;
}
.indicator {
position: absolute;
top: 0;
left: 37px;
background-color: red;
}
</style>
</head>
<body>
<!-- auto margins -->
<div class="group" style="top: -300px">
<div class="indicator box" style="top: 110px;"></div>
<div class="container">
<div class="sticky box" style="margin: auto; top: 280px"></div>
</div>
</div>
<!-- px margins -->
<div class="group" style="top: -300px">
<div class="indicator box" style="top: 37px;"></div>
<div class="container">
<div class="sticky box" style="margin: 20px; top: 240px"></div>
</div>
</div>
<!-- % margins -->
<div class="group" style="top: -300px">
<div class="indicator box" style="top: 37px;"></div>
<div class="container">
<div class="sticky box" style="margin: 20%; top: 220px"></div>
</div>
</div>
<!-- % margins -->
<div class="group" style="top: -300px">
<div class="indicator box" style="top: 37px;"></div>
<div class="container" style="width: 200px;">
<div class="sticky box" style="margin: 20%; top: 200px"></div>
</div>
</div>
</body>
</html>