<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0;
overflow: hidden; /* hide scrollbars */
}
.container {
position: absolute;
width: 200px;
height: 400px;
margin: 10px;
left: 200px;
top: -300px;
outline: 2px solid black;
}
.spacer {
height: 350px;
width: 20px;
background-color: black;
}
.vertical .spacer {
height: 20px;
width: 350px;
}
.vertical.container {
-webkit-writing-mode: vertical-rl;
top: 200px;
left: 700px;
width: 400px;
height: 200px;
}
.box {
width: 150px;
height: 150px;
}
.sticky {
position: relative;
background-color: green;
opacity: 0.75;
}
</style>
</head>
<body>
<div class="container">
<div class="spacer"></div>
<div class="sticky box"></div>
</div>
<div class="vertical container">
<div class="spacer"></div>
<div class="sticky box"></div>
</div>
</body>
</html>