Visit this link to view the code snippet.
I am dealing with a parent container that contains two scrollable blocks, one of which is absolutely positioned. This layout is necessary in order to create a wrapper with border-radius properties. Both blocks are guaranteed to have the same width.
.container {
width: 400px;
border: 1px solid #ccc;
height: 100px;
overflow: auto;
margin: 0 auto;
position: relative;
font-size: 18px;
white-space: nowrap;
}
.head {
overflow: auto;
height: 40px;
}
.container .body {
border: 2px solid #c4c;
position: absolute;
border-radius: 16px;
right: 0;
left: 0;
bottom: 0;
height: 50px;
overflow: auto;
}
<div class="container">
<div class="head">
we like it, but a person who isn't familiar with his story may have some difficulty seeing how it would be so fitting, but it's hard to ignore the similarities between this dog and cat.
</div>
<div class="body">
we like it, but a person who isn't familiar with his story may have some difficulty seeing how it would be so fitting, but it's hard to ignore the similarities between this dog and cat.
</div>
</div>
My attempt to synchronize the scrolling behavior using JavaScript resulted in flickering and did not feel like an ideal solution. I am seeking a method to make both scrollable blocks move synchronously as if they were one block, without relying on JavaScript. Is there a way to achieve this?