So basically I want a div that is in the middle of screen and it is fixed there, but only in the x-axis, so no matter if I scroll left or right, it stays in the middle of the screen however when I want to scroll down I want to it to scroll away just like it would if it were relative. I hope you understand what I mean.
This is the code that I’ve put for that div so far when trying to achieve this.
#header{
position:fixed;
top:0px;
left:50%;
margin-left:-100px;
width:200px;
height:160px;
}
This code has it fixed in both the x-plane and y-plane, so that when I scroll down it stays in the same spot on the screen and it doesn’t go away as I scroll down like it would if it were relative.
Cohl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.