Html CSS 绝对位置,其中 div 的左上角位于父级的右上角
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11434061/
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
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:35:27 来源:igfitidea点击:
CSS absolute position where top left of div is at the top right of the parent
提问by Ashwin
回答by madeye
I think you want something like this
我想你想要这样的东西
<div id = "parent">
<div id = "child"></div>
</div>
#parent {
position: relative;
width: 500px;
height: 500px;
background: red;
display: block; /* fix for opera and ff */
}
#child {
position: absolute;
width: 100px;
height: 100px;
background: blue;
top: 0;
left: 100%; /* this line of code will sort things out for you :) */
}
回答by silentw
Simple as this?
就这么简单?
CSS:
CSS:
div {border:1px solid #000}
.p {
position:relative;
width:100px; /*width will be unknown*/
height:80px;
background:#999;
}
.c {
position:absolute;
width:40px;
height:30px;
background:red;
top:0;
left:100%;
}
? HTML:
? HTML:
<div class="p">
<div class="c"></div>
</div>?