Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created an html code and CSS sheet. When I placed items using absolute positioning, using top and left, if I move the entire page from left side these items also seem to move in that way. What can I do to make sure when I scroll up or down, it stays the same.

.cont{
position: absolute;
top:10px;
right:30px;
}

What I have tried:

I have tried different positions other than absolute and even flexbot to place the items evenly and ensure that when I move, it also moves. None of them seem to work.
Posted
Updated 29-Jan-21 2:20am

On the very rare occasion I needed that effect, it was position:fixed

Now one thing you should be aware of: when you use positioning, it is often related to the containing element (i.e., if you wrap your elements in a <div> then the absolute position is relative to that <div>).

If you want to fix an elements to a particular position, treat it as external to all of the other elements (and why not? it's expected to ignore them).


 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900