I have scrollable text on top which has dynamic height according to content bellow that have sticky header which also has dynamic height below that I am trying to add another sticky header but for this second header I am not sure how much top should I give? Is there any trick to calculate position on runtime or is there any other way?
.container {
height: 200px;
overflow: scroll;
}
.content {
background-color: gray;
}
.header1 {
position: sticky;
top: 0px;/* or whatever you wish to see it sticks */
background-color: red;
}
.header2 {
position: sticky;
top: 0px;/* how to stick thi div below header1 */
background-color: blue;
}
.footer {
/*top: 10px;*//* useless if position is not reset to fixed,absolute or sticky */
background-color: yellow;
height: 400px;
}
<div class="container">
<div class="content"> runtime example text<br> runtime example text<br> runtime example text </div>
<div class="header1"> header text runtime dynamic text </div>
<div class="header2"> header text </div>
<div class="footer"> footer text </div>
</div>