An expanded question on :
pure CSS multiple stacked position sticky?
is there a way to calculate the top position of the followup header in order to stack the headers as per the the example. I do not know the count of the amount of headers there will be so i cannot say:
.headers {position:sticky}
.header-1 {top:0;}
.header-2 {top:1em}
.header-3 {top:2em}
.header-4 {top:3em}
but would need to calculate the difference
HTML:
<div class="container">
<div class="headers header-1">header 1<div>
<div class="content">This is the content<div>
<div class="headers header-2">header 2<div>
<div class="content">This is the content<div>
<div class="headers header-3">header 3<div>
<div class="content">This is the content<div>
<div class="headers header-4">header 4<div>
<div class="content">This is the content<div>
I would need to somehow calculate the :nth-child or :type-of or so method as the list grows. not sure if it could be done in css but would like to know if it is possible