简体   繁体   English

Bootstrap,使行填充剩余的屏幕空间

[英]Bootstrap, make row fill remaining screen space

I'm trying to make a site where the header must have a height of 13% and section1 must fill the rest of the screen perfectly and below that the same case with section2 plus the footer, so if the user scrolls all the way down those last two will fit the screen. 我正在尝试建立一个网站,其标题必须具有13%的高度,并且section1必须完美地填充屏幕的其余部分,并且在第2部分加上页脚的情况下是相同的情况,因此如果用户向下滚动那些最后两个适合屏幕。

I've been on this for a good time, the problem I have is that the container doesn't grow beyond is height so there's an overflow with section2 and the footer gets on top of it. 我已经度过了一段美好的时光,我遇到的问题是容器不会超出高度,所以有一个溢出的section2和页脚在它上面。 I was trying this: 我在尝试这个:

Expanding the parent container with 100% height to account for floated content 扩展具有100%高度的父容器以考虑浮动内容

but couldn't make it work. 但无法使其发挥作用。

My original code is a mess so I tried to clean it the best I could to focus on this. 我的原始代码是一团糟,所以我尽力清理它,我可以专注于此。 It looks like this: 它看起来像这样:

HTML HTML

<header> </header>
<div class="container-fluid">
    <div id="section1" class="row-fluid fill-height" >
        <div  class="span6" id="red-space">
                <!-- STATIC CONTENT -->
        </div>
        <div class="span6">
                <!-- STATIC CONTENT -->
        </div>
    </div>
    <div id="section2" class="row-fluid fill-height">
                <!-- STATIC CONTENT -->
    </div>
</div>

CSS CSS

html, body
{
  height: 100%;
}

body{
    background-color:#fafafa;
    color:#5b5b5b;
    min-width:0;
}

header, footer {
    height: 13%;
}

.container-fluid {
    padding: 0;
    min-height:83%;
    height: 83%;
    overflow: hidden;
}

.fill-height{
    height:100%;
}

I would try adding class fill-height for the div with class container-fluid. 我会尝试使用类container-fluid为div添加类填充高度。 That might work. 那可能有用。 Or it's not the best practice, but try adding it inline. 或者这不是最好的做法,但尝试将其添加到内联中。 I find sometimes for whatever reason inline will work even if putting it within the css doesn't. 我发现有时无论出于何种原因内联即使将其置于css中也不会有效。 Let me know if that doesn't work. 如果这不起作用,请告诉我。 Good luck! 祝好运!

Your problem seems to be a footer which won't stay down and creeps up? 你的问题似乎是一个不会停留下来并爬起来的页脚? This is a common issue, there should be several examples to work from with a quick search. 这是一个常见问题,应该有几个例子可以通过快速搜索来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM