When i use {position:fixed} and scroll it moves a bit upward and then the attribute works ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

When i use {position:fixed} and scroll it moves a bit upward and then the attribute works ?

eg. - I made a div element and I put the the position to fixed , div { position:fixed; width:100%; height:10%; top:0%; left:0%; } when I scroll downward it moves a bit upward and then the fixed attribute works . How to prevent that from happening?

17th Feb 2017, 3:02 PM
Utkαrsh
Utkαrsh - avatar
4 Answers
+ 12
Put your whole page except the fixed tag inside a <div> and make it fullscreen. This way the user will scroll the <div> and not the whole page.......
17th Feb 2017, 3:09 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 13
try above and : html, body { overflow:hidden; }
17th Feb 2017, 3:23 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 5
@valentin it acted really weird when i put the width of the div (covering everything) below 90% it worked else the same condition
17th Feb 2017, 3:21 PM
Utkαrsh
Utkαrsh - avatar
+ 5
sorry my mistake, I put one elements width to 100% with additional padding , now it works thanks
17th Feb 2017, 3:41 PM
Utkαrsh
Utkαrsh - avatar