I have a sticky div
in the middle of the screen. As user scrolls down the div scrolls down also. I require slightly different behavior.
The div
has to be stuck and scrolled down with page as soon as the top of the page reaches this sticky div.
Is it possible to achieve this with only pure CSS, or do I need to use jQuery as well?
.container {
height: 1500px;
background-color: gray;
}
.badge {
position: fixed;
width: 270px;
height: 100px;
text-align: left;
background-color: green;
overflow: hidden;
z-index: 1020;
right: -6%;
top: 30%;
}
.badge .badge-text {
position: absolute;
color: #ffffff;
}
.badge .text1,
.badge .text3 {
font-weight: bold;
font-size: 1rem;
}
<div class="container">
<div class="badge">
<div class="badge-text">
<span class=" text1">TEXT 1</span><br>
<span>TEXT 2 </span><br/>
<span class="text3">TEXT 3</span>
</div>
</div>
</div>
Fiddle: http://jsfiddle.net/mLzevpy3/