Can position:relative and position:fixed be used together?
I have a Div container that contains a pen outline, with a z-index of 5, position: relative. When the viewer chooses an underlay graphic with z-index -2, position: absolute; it works fine but if the viewer scrolls down for more underlay choices, the pen outline scrolls off the top. How do I make the pen outline relative AND fixed so it stays on the screen when scrolling down?
7 Replies
Please share example code in a codepen or similar, it's not clear what you're asking from this description
i think you need position absolute
but it sounds like you're over-overcomplicating
position fixed is position relative to the screen,
position relative is position relative to its static position,
position absolute is position relative to its parent which isn't static.
For detailed help, provide the code since like Alex said, its not really clear what you want to achieve.
Yes. postion absolute works inside a postion fixed parant just like how it would if it was a potion relative parent if that's what the original poster is asking
Maybe what you need is postion sticky so that the outline shows normaly when not scrolling and remains on screen when you scroll
we're just guessing
I meant can they BOTH be used in the same Div/Container?
in the exact same element?
no
obviously
you can have one or the other
but, again, there might be a solution, but we need to see the code
and no, screenshots don't run in codepen or jsfiddle