why position absolute is not working properly here with overflow hidden?

Hi Hi, been watching kevin's video:https://www.youtube.com/watch?v=HbBMp6yUXO0&t=2482s (Responsive navbar tuto) and I want to ask something, why wen put position:absolute instead of fixed and I add the overflow hidden to the body it still crashes but with postion:fixed everything working fine https://stackblitz.com/edit/stackblitz-starters-awbn35hq?file=styles.css
No description
6 Replies
Kevin Powell
Kevin Powell2w ago
Looking at it quickly now, I don't see the difference between when fixed and absolute in the example unless you fixed it?
omar_ab(@om4rAb)
omar_ab(@om4rAb)OP2w ago
if you open the preview in a new tab then inspect it u will get what's in the provided pic
omar_ab(@om4rAb)
omar_ab(@om4rAb)OP2w ago
omar_ab(@om4rAb)
omar_ab(@om4rAb)OP2w ago
sorry for the noise in the video hhhhhh
Kevin Powell
Kevin Powell2w ago
Ah, I get it now, sorry. When something is fixed, it's fixed to the viewport and has no impact on scrolling, so it doesn't add overflow if it's off to the side. If it did, and we scrolled over, we'd never be able to get to it, because it's fixed outside of view. Absolute, while coming out of the flow of the document, it's still part of the layout, so it will cause overflow.
omar_ab(@om4rAb)
omar_ab(@om4rAb)OP2w ago
aah ok so is even overflow hidden won't solve the problem and better use fixed

Did you find this page helpful?