我有一个位于浏览器右侧的 div 框,顶部边框很好,但我需要框的底部距离浏览器底部 140 像素,但我做不到似乎让这个工作。
有什么想法吗?
#nav-right {
position: absolute;
top:120px;
bottom: 140px;
right: 0;
width: 120px;
height: 100%;
}
最佳答案
您的代码过度约束,因为您为 top
、height
和 bottom
指定了明确的长度。
两个约束就够了。不要指定高度
,让它成为默认的auto
。
#nav-right {
position: absolute;
top: 120px;
bottom: 140px;
right: 0;
width: 120px;
background: blue;
}
<div id="nav-right"></div>
关于css - 在 div 上设置 margin-bottom 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35708739/