gpt4 book ai didi

html - 绝对位置在固定位置内不起作用

转载 作者:行者123 更新时间:2023-11-28 02:54:28 25 4
gpt4 key购买 nike

<div id="main" style="position: fixed">
<div id="inner" style="position: absolute">
</div>
</div>

maininner 容器都采用position: fixed。如何使用 position:absolute 制作内部容器和使用 position:fixed 制作主容器?

最佳答案

使用fixed<时需要定义top, right, bottom or left 属性relativeabsolute 元素定位。

#main {
background: #000;
position: fixed;
height: 300px;
width: 200px;
left: 20px;
top: 10px;
}
#inner {
background: #f00;
position: absolute;
height: 100px;
width: 100px;
left: 10px;
top: 10px;
}
<div id="main">
<div id="inner">
</div>
</div>

关于html - 绝对位置在固定位置内不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37783835/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com