css - 在 div 上设置 margin-bottom 不起作用

标签 css

我有一个位于浏览器右侧的 div 框,顶部边框很好,但我需要框的底部距离浏览器底部 140 像素,但我做不到似乎让这个工作。

有什么想法吗?

#nav-right {
	position: absolute;
	top:120px;
	bottom: 140px;
	right: 0;
	width: 120px;
	height: 100%;
}

最佳答案

您的代码过度约束,因为您为 topheightbottom 指定了明确的长度。

两个约束就够了。不要指定高度,让它成为默认的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/

相关文章:

javascript - 在 magiczoomplus 中添加分享按钮

javascript - js 中的多个 if 条件未提供所需的输出

php - 标签打印机的 CSS

javascript - 如何在 Angular 应用程序中制作自定义上下文菜单?

CSS Grid 错误(使用 Grid Polyfill)

html - float 列表项占据特定宽度

php - 每行 Wordpress/WooCommerce 产品

javascript - 使抽屉内的按钮可点击?

css - 具有响应内容的 Bootstrap 粘性页脚

android - 在移动设备上运行的 GWT 应用程序