Html 绝对位置,右上角(调整大小)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12718514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Position absolute, top right hand corner (resizing)
提问by user82302124
Should be really simple... I thought.
应该很简单……我想。
I have a set up as such:
我有一个这样的设置:
<div id="main">
<div id="a1">THE FIRST</div>
<div id="a2">THE SECOND</div>
</div>
I want the entire main div to be positioned at the top right hand corner of my screen and when I resize the browser, I want it to STAY there. I'm not talking fixed positioning - Just absolute.
我希望整个主 div 位于屏幕的右上角,当我调整浏览器大小时,我希望它留在那里。我不是在谈论固定定位 - 只是绝对的。
However, this css isn't working. Any ideas?
但是,这个 css 不起作用。有任何想法吗?
#main {
position:relative;
top:0;
right:0;
z-index:300;
min-width:0;
width:8%;
}
#main #a1 {
position:absolute;
background: #082540;
z-index: 300;
right:0;
top:40px;
}
#main #a2 {
position:absolute;
background: #082540;
z-index: 300;
right:0;
top:0;
}
** EDIT **
** 编辑 **
If I put the div at the top right hand, I want it to disappear (like "fixed") when I bring the browser in from right to left.
如果我将 div 放在右上角,当我从右到左打开浏览器时,我希望它消失(如“固定”)。