简体   繁体   中英

How can I position my userControl to the top right corner of my MasterPage?

使用CSS,如何定位控件,使其始终显示在浏览器的右上角?

Use absolute positioning and set the top/right attributes.

#control {
    position: absolute;
    right: 0px;
    top: 0px;
}

If you want it to remain on the top right even as you scroll down, you're probably looking at a javascript solution that repositions the element as the page is scrolled.

You can use position: fixed to place the content at a fixed location in the viewport. This content will not scroll with the rest of the page. Note that IE6 does not support this CSS setting, so if you need to support that browser, then you are stuck with using JavaScript to achieve the same effect, as already mentioned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM