html - 宽度被忽略(基本 html)

标签 html css

<body>
  <div style="position:absolute;top:0px;left:0px;width:200px;bottom:100%;background:#aeaeae;"></div>
  <div style="position:absolute;top:0px;left:200px;width:calc(100% - 200px);bottom:100%;background:#ffffff;"></div>
</body>

为什么宽度呈现为 0px(在 chrome 上)?

这是非常简单的 HTML/CSS 代码

最佳答案

这些元素的 width 在 Chrome 中不呈现为 0px高度是。您尚未定义这些元素高于 0px 的任何原因。

如果您将 bottom: 100% 规则更改为 bottom: 0,您的元素将从其父元素的顶部延伸到底部。

<body>
  <div style="position:absolute;top:0;left:0;width:200px;bottom:0;background:#aeaeae;"></div>
  <div style="position:absolute;top:0;left:200px;width:calc(100% - 200px);bottom:0;background:#ffffff;"></div>
</body>

关于html - 宽度被忽略(基本 html),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57154096/

相关文章:

javascript - 如何在 Eclipse IDE 中验证 HTML、CSS 和 JS

css - BEM CSS : Similar blocks and style sharing

html - 将表格转换为 AutoResize Div

javascript - 如何使用 JavaScript 进行验证

html - 如何消除网站边框和图像之间的差距?

javascript - png 文件上的颜色蒙版

asp.net - 我该如何解决这个陈述

html - IE 7 和 8 未显示完美的设计 View

php - 在不换行的情况下在 div 中显示内容

javascript - 选择输入类型编号中的所有输入值