html - 容器高度 100% - px

标签 html css calc

我正在尝试做一个简单的结构。

标题(35 像素高度)、容器(100% 高度)和底部(35 像素高度)。

为此,我使用 height: calc(100% - 72px);高度:-webkit-calc(100% - 72px);高度:-moz-calc(100% - 72px),但不适用于 Safari v5 和 IE ...

http://jsfiddle.net/2kng68pa/

我也尝试过使用 magin-top 但是......这是浪费时间。

拜托,有人可以帮助我吗?我需要与 jsfiddle 相同的结果但与 IE 和 Safari V5 兼容 ...

提前致谢。

最佳答案

如果 header 和 bottom 的高度是固定的,那么剩下的就很简单了:

html,
body { height:100%; }
* { box-sizing: border-box; margin:0; padding:0; }
header,footer { height: 35px; background: #0ff; color: #fff; position:absolute; left:0; right:0;}
header { top:0; }
footer { bottom:0; }
.container { background: #0f0; height: 100%; padding: 35px 0;}
<header>Header</header>
<div class="container">
  Container
  </div>
<footer>Footer</footer>

关于html - 容器高度 100% - px,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26897880/

相关文章:

css - 对 CSS 中的数据属性(例如模数)执行计算 (calc)

随内容增长的 CSS 选项卡

javascript - 当我更正无效的输入并尝试再次提交时,代码将不会执行

jquery - 如何使用 jquery 将值更改为类型文件的输入字段

html - iOS6 CSS3 3D 变换非常慢

html - 将链接样式重置为包含 div 中的图像的 <A>

html - Calc 100% 应用于 div,而不是 h2

html - 如何将消息发送到 OpenID URL..?

php - 在 Drupal 中为 IE 添加条件样式

delphi - 是否有适用于 Delphi(非 OLE)的 OpenOffice.org 导出组件?