绝对位置不起作用,内部位置固定
问题描述:
<div id="main" style="position: fixed">
<div id="inner" style="position: absolute">
</div>
</div>
main
和inner
容器均使用position: fixed
.如何使用position:absolute
制作内部容器和使用position:fixed
制作主容器?
Both main
and inner
containers taking position: fixed
. How to make inner container with position:absolute
and main container with position:fixed
?
答
您是否正在寻找类似的东西?
Are you looking for something similar ?
<div id="main">
<div id="inner">
</div>
</div>
#main {
position: fixed;
width: 100px;
height: 100px;
border: 1px solid #000;
top: 50px;
left: 10px;
}
#inner {
position: absolute;
width: 10px;
height: 10px;
border: 1px solid #f00;
// top: 0px;
// left: 0px;
top: 10px;
left: 10px;
}