How do I make a DIV always float on the screen's top right corner, so that even when I scroll the page down, the DIV still shows up in the same fixed location? Thanks.
Set the DIV's z-index to one larger than the other DIVs. You'll also need to make sure the DIV has a position other than static set on it, too. position relative and z index set to 999999999999999999999999999999999999999999999999999.
If you want to move the div container, make sure the container is set as position "relative." Then adding style="float: right;" will work. If you want to only move the div within that container, then you need to use float="right" on that particular element (object) instead of positioning it with a style.
Use position: fixed
, and anchor it to the top
and right
sides of the page:
#fixed-div { position: fixed; top: 1em; right: 1em; }
IE6 does not support position: fixed
, however. If you need this functionality in IE6, this purely-CSS solution seems to do the trick. You'll need a wrapper <div>
to contain some of the styles for it to work, as seen in the stylesheet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With