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
Alex
Alex4mo ago
Please share example code in a codepen or similar, it's not clear what you're asking from this description
ἔρως
ἔρως4mo ago
i think you need position absolute but it sounds like you're over-overcomplicating
Smix
Smix4mo ago
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.
vagge_b
vagge_b4mo ago
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
ἔρως
ἔρως4mo ago
we're just guessing
Lonnie
LonnieOP4mo ago
I meant can they BOTH be used in the same Div/Container?
ἔρως
ἔρως4mo ago
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
Want results from more Discord servers?
Add your server