- on the 1st picture when the scroll reaches the parent element the sticky element sticks on the bottom of the screen (as expected)
- on the 2nd picture when the scroll centers the sticky element it does not stick anywhere
- on the 3rd picture the when the scroll goes further the sticky element stick on the top of the screen (as expected)
Here is my question :
- as far as I understand the sticky position switches to "position:fixed" when the sticky element reaches its position on the viewport
- on the 2nd picture that is definitely not the case because the sticky element does not stick neither the top nor the bottom of the screen
- why is that what the sticky element is doing on the 2nd picture exactly?
.parentSticky {
width: 50%;
height: 800px;
border: solid black 5px;
display: flex;
flex-direction: column;
align-items: center;
margin: auto;
}
.siblingSticky {
width: 100%;
height: 100px;
background-color: orange;
border: solid 10px red;
display: inline-block;
flex: 50 0 1px;
box-sizing: border-box;
}
.Istick {
flex-grow: 1;
border: solid 10px green;
box-sizing: border-box;
position: sticky;
bottom: 10px;
top: 10px;
}
<!-- break tags illustrate the page's other contents (scrolling demo) -->
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<div class="parentSticky">
<div class="siblingSticky"> Element </div>
<div class="siblingSticky Istick" > "Sticky" element </div>
<div class="siblingSticky"> Element </div>
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>