Make just an child-element sticky

I want just to have the time on the left side sticky, not the whole element (like in the second video). Is there an easy solution without "doubling" the list and make the left / right element hidden? the list elements are currently written in flex like
<div class="entry">
<div>Starting Time</div>
<div>Sessions</div>
</div>

.entry {
display: flex;
}
<div class="entry">
<div>Starting Time</div>
<div>Sessions</div>
</div>

.entry {
display: flex;
}
13 Replies
Mannix
Mannix•11mo ago
I assume the Starting time has position sticky?? and it doesn't work? Since you use flexbox on the entry to put them side by side try adding align-self: start; to the Starting time.
bibamann
bibamannOP•11mo ago
<div class="entry">
<div>Starting Time</div>
<div>Sessions</div>
</div>

.entry {
position: sticky;
top: 100px;
display: flex;
}
<div class="entry">
<div>Starting Time</div>
<div>Sessions</div>
</div>

.entry {
position: sticky;
top: 100px;
display: flex;
}
is the 2nd video. putting sticky on the div with "starting time" is basically the first one - nothing happens
Mannix
Mannix•11mo ago
sticky should be on the starting time div not the entry
bibamann
bibamannOP•11mo ago
yes and there nothing happens I can do a jsfiddle on it if it helps
Mannix
Mannix•11mo ago
did you added align-self: start; there too as i said? it will help tremendously 🙂
bibamann
bibamannOP•11mo ago
... thx I don't understand it, but it works.
Mannix
Mannix•11mo ago
by default the children are streaching so they have equal height 🙂 so there is no room for sticky to work you could also use align-items: start on the parent by default it's set to stretch
bibamann
bibamannOP•11mo ago
🙂
bibamann
bibamannOP•11mo ago
I had it on the parent - it must be on the "starting time" one
Mannix
Mannix•11mo ago
Kevin Powell
YouTube
When position sticky doesn't stick
Sometimes position sticky doesn't stick, so let's see why it doesn't and how we can fix it!
bibamann
bibamannOP•11mo ago
this Kevin guy is scary how can I set this to "solved"?
Mannix
Mannix•11mo ago
nah he is our friend 😄 there should be solved tag
bibamann
bibamannOP•11mo ago
yea... I can't see where to edit the tags (using discord on browser)

Did you find this page helpful?