【问题标题】:Set the correct height dimension of a three-row-layout设置三行布局的正确高度尺寸
【发布时间】:2015-05-07 06:57:37
【问题描述】:

如何创建具有以下高度的三行:

  1. 标题应为 70px
  2. 主屏幕应占屏幕的 30%
  3. 页脚应该占据其余空间

body {
  width: 100%;
  height: 100%;
  margin: 0px;
  padding: 0px;
}
header {
  background-color: red;
  height: 70px;
  z-index: 10;
  position: relative;
}
main {
  background-color: green;
  height: 30%;
  position: relative;
}
footer {
  background-color: #ddd;
  /* height? */
}
<body>
  <header></header>
  <main></main>
  <footer></footer>
</body>

【问题讨论】:

标签: html css


【解决方案1】:

你可以使用

width: calc(70% - 70px);

在页脚,请在此处查看浏览器支持 http://caniuse.com/#feat=calc

【讨论】:

    猜你喜欢
    • 2016-08-02
    • 2021-10-28
    • 2011-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-10
    • 2017-07-15
    • 2022-01-19
    相关资源
    最近更新 更多