I am trying to fix a div
so it always sticks to the top of the screen, using:
position: fixed;
top: 0px;
right: 0px;
However,
The answer is yes, as long as you don't set left: 0
or right: 0
after you set the div position to fixed.
http://jsfiddle.net/T2PL5/85/
Checkout the sidebar div. It is fixed, but related to the parent, not to the window view point.
body {
background: #ccc;
}
.wrapper {
margin: 0 auto;
height: 1400px;
width: 650px;
background: green;
}
.sidebar {
background-color: #ffffd;
float: left;
width: 300px;
height: 100px;
position: fixed;
}
.main {
float: right;
background-color: yellow;
width: 300px;
height: 1400px;
}
wrapper
main