I am trying to make it so that half a relatively positioned div has one specific color.
I tried creating another div and place it in position absolute with a width of 50% and placed to the right but the issue I am running into is that since my content is scrollable, whenever I reach the spot where it starts scrolling, the background of that div stops.
Should be mentioned that the reason why I am not simply creating 2 divs each with one color is that I have content placed in the middle as well.
Is there a way around this?
.wrapper {
position: relative;
width: 200px;
height: 200px;
background: red;
overflow-y: auto;
}
.right-section-background {
position: absolute;
right: 0;
width: 50%;
height: 100%;
background: yellow;
}
.content {
position: absolute;
}
<div class="wrapper">
<div class="right-section-background"></div>
<div class="content">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Omnis repudiandae officia quasi reiciendis rerum, maiores venia consectetur culpa esse voluptatum ipsam sint velit labore atque libero tempora quas est neque.</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Omnis repudiandae officia quasi reiciendis rerum, maiores venia consectetur culpa esse voluptatum ipsam sint velit labore atque libero tempora quas est neque.</p>
</div>
</div>