How to make a DIV always float on the screen in top right corner?

后端 未结 2 1032
执念已碎
执念已碎 2020-12-08 09:22

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.

2条回答
  •  臣服心动
    2020-12-08 09:57

    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

    to contain some of the styles for it to work, as seen in the stylesheet.

提交回复
热议问题