I had a situation where I used the fixed
position
for a div
on a webpage to keep it stuck at the top like a header. However, when scrolling, it ended up getting hidden behind other elements such as divs
, videos, and text!
Here's how the div
should always appear:
And here is how the div
disappears when scrolled down:
I came up with a basic idea that if I write the code for that specific div
first (which I did) and then add code for other objects, those objects would naturally come in front. One solution could be to place its code at the end. But I have an organized structure with well-placed comments in between, so this option might disrupt it.
This is the current code snippet:
<div style="width: 1409.25px; height:40px; top:0; left:0; position:fixed; background-color:black; line-height:2;">..Text here..</div>
Is there a way to ensure that the div
stays visible in front while scrolling without shifting its code to the end?