【问题标题】:100% height div container not working with header100% 高度的 div 容器不适用于标题
【发布时间】:2015-10-25 09:13:24
【问题描述】:

http://jsfiddle.net/oedev/pag7ahz2/

我有以下页面布局:

  • cMain - 主页容器
  • cBanner - 横幅容器
  • cNavigation - 导航容器
  • cContent - 页面内容容器

所有这些都设置为 100%,因为我希望页面内容的大小设置为 100%(横幅除外)。

html, body {
    height: 100%;
}

#cMain {
    height: 100%;
}

#cBanner {
    background: #002d62 top center no-repeat scroll;  
    height: 200px; 
    margin-bottom: 1em; 
    margin-top: 1em;    
}

#cContent {
    height: 100%
}

我已将 html、body 和包含 div 的高度设置为 100%。

但是,由于我有一个标题徽标和导航栏,因此这些下的 div 的大小不是 100%(我最终得到了一个滚动条)。

如果我删除标题和导航栏 div,内容 div 的大小为 @ 100%,没有滚动条。

【问题讨论】:

  • 嗨,我认为您需要将 height:auto ** 应用于 html,body 而不是 **100%

标签: html css twitter-bootstrap


【解决方案1】:

从body标签中移除高度。

html {
    height: 100%;
}

或者如本文所示为身体设置一个最小高度:Make body have 100% of the browser height

html {
    height: 100%
}
body {
    min-height: 100%;
}

【讨论】:

  • 谢谢,移除 html 标签上的 100% 高度在一定程度上是可行的,因为它移除了滚动条。在我的内容容器 div 中,我托管了一个 Kendo ui 网格,其中包括分页控件。如果我扩大我的窗口的大小,我希望这些会转移到我的窗口底部。这没有发生。基于此示例:jsfiddle.net/dimodi/SDFsz
猜你喜欢
  • 2015-09-05
  • 2010-09-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-22
  • 2020-01-02
  • 2011-04-29
  • 2012-02-04
相关资源
最近更新 更多