Reputation: 1586
I'm building a React app, and I'm having a problem with position: sticky
in my story-header
element. I already checked the parent styles and there's no overflow: hidden
attribute-value.
HTML
<div className='StoryList' >
<div className='story-header'></div>
</div>
CSS - Stylesheet
.App {
width: 100%;
overflow: visible;
}
.StoryList {
position: relative;
margin: 0;
width: 100%;
}
.story-header {
width: 100%;
top: -20px;
height: 50px;
left: 0;
background-color: lightgray;
position: sticky;
z-index: 1;
}
Why is the story-header
sliding above the top?
Upvotes: 1
Views: 4170
Reputation: 1
It is may be very strange, but in my case the deleting of the font-size: 100%; and the font-size: inherit; in the zero-styles helped me to solve the issue!
Upvotes: 0
Reputation: 51
well i am also having the same problem turns out i need to set the height of the app and root to inherit, trying doing it and it should work then
Upvotes: 1
Reputation: 148
I'm not sure that I understood you correctly, but it works as it should. I've tried it in pure html/css and it's working. Check my code, buddy:
.App {
width: 100%;
height: 200vh;
overflow: visible;
}
.StoryList {
background: #000;
height: 40vh;
position: fixed; // you can comment it out, I'm not sure what would you like to have
margin: 0;
width: 100%;
}
.story-header {
width: 100%;
top: -20px;
height: 50px;
left: 0;
background-color: lightgray;
position: sticky;
z-index: 1;
}
Check both versions - with fixed position and without it.
Upvotes: 1