Create a cool fixed scroll sidebar without javascript and a few lines of css.
Fixed vertical div with flexible horizontal positioning.
The fixed div in the script below is apparently located relative to the container, but this is just an illusion.
FIXED DIVS ALWAYS POSITIONED REGARDING THE SCREEN.
ABSOLUTE DIVS ALWAYS ARISE ABOUT THEIR NEAREST PROVISION: RELATIVE CONTAINER.
HTML
<div class="Wrap">WRAP</div> <div class="Fixed">FIXED</div>
CSS
.Wrap{ background:#ccc; width:600px; height:300px; margin:0 auto; } .Fixed{ position:fixed; top:20px; right:50%; background:#333; height:100px; width:50px; margin-right:-360px; }
The illusion of a div, which appears both absolute and fixed, is achieved using a negative margin and a container with a fixed width.
http://jsfiddle.net/9HQ4b/2/
Small version of the site for screens of smaller width.
http://jsfiddle.net/9HQ4b/3/
Obsidian
source share