I've created a sidebar, where I have three container elements. I want them to be sticky as the user scrolls through the page and when the user reaches the footer I want these elements to behave like normal elements and not overlap with each other.
Here is the code representing the problem. How to resolve this overlapping issue?
<div class="sidebar">
<div class="sidebar-subscription-form-container">
<div class="sidebar-subscription-form">
<p>I would hold all the subscription form elements</p>
</div>
</div>
<div class="social-buttons-container">
<div class="social-buttons">
<p>
I would contain all the social buttons
</p>
</div>
</div>
<div class="sidebar-banner-container">
<div class="sidebar-banner">
<p>
Here is the sidebar banners
</p>
</div>
</div>
</div>
.sidebar-subscription-form-container {
top: 0px;
height: 30px;
z-index:1;
position: sticky;
}
.social-buttons-container {
top: 400px;
height:30px;
z-index:1;
position: sticky;
}
.sidebar-banner-container {
top: 800px;
height:30px;
z-index:1;
position: sticky;
}