我试图用Twitter Bootstrap 3做一个两列全高布局。Twitter Bootstrap 3似乎不支持全高布局。 我想做的是:

  +-------------------------------------------------+
  |                     Header                      |
  +------------+------------------------------------+
  |            |                                    |
  |            |                                    |
  |Navigation  |         Content                    |
  |            |                                    |
  |            |                                    |
  |            |                                    |
  |            |                                    |
  |            |                                    |
  |            |                                    |
  +------------+------------------------------------+

如果内容增长,导航也应该增长。

高度100%为每个父级是行不通的,因为有些情况下内容是一行。 立场:绝对似乎是错误的方式。 Display: table和Display: table-cell解决了这个问题,但不够优雅。

HTML:

    <div class="container">
      <div class="row">
        <div class="col-md-3"></div>
        <div class="col-md-9"></div>
      </div>
    </div>

有办法使它与默认的推特引导3类?


当前回答

现代且非常简单的解决方案:

HTML:

<div class="container">
  <div class="row">
    <div class="col-md-3"></div>
    <div class="col-md-9"></div>
  </div>
</div>

CSS:

.row {
    display: flex;
}

其他回答

据我所知,你可以使用5种方法来完成这个任务:

使用CSS显示表/表格单元格属性或使用实际的表。 在包装器内使用绝对定位元素。 使用Flexbox显示属性,但到今天为止,它仍然有部分支持 使用伪列技术模拟全列高度。 使用填充/边距技术。看到的例子。

Bootstrap:我在这方面没有太多经验,但我不认为他们提供了这样的样式。

.row
{
    overflow: hidden;
    height: 100%;
}
.row .col-md-3,
.row .col-md-9 
{
    padding: 30px 3.15% 99999px; 
    float: left;
    margin-bottom: -99999px;
}
.row .col-md-3 p,
.row .col-md-9 p 
{
    margin-bottom: 30px;
}
.col-md-3
{
    background: pink;
    left:0;
    width:25%
}
.col-md-9
{
    width: 75%;
    background: yellow;
}

试试这个

 <div class="container">
     <!-- Header-->         
  </div>
</div>
 <div class="row-fluid">
     <div class="span3 well">
         <ul class="nav nav-list">
             <li class="nav-header">Our Services</li>
                <!-- Navigation  -->
             <li class="active"><a href="#">Overview</a></li>
             <li><a href="#">Android Applications</a></li>
             <li class="divider"></li>
         </ul>
     </div>
     <div class="span7 offset1">
      <!-- Content -->         
     </div>
 </div>

访问http://www.sitepoint.com/building-responsive-websites-using-twitter-bootstrap/

感谢Syed

纯CSS解决方案

工作小提琴

仅使用CSS2.1,适用于所有浏览器(IE8+),不指定任何高度或宽度。

这意味着如果你的标题突然变长了,或者你的左侧导航需要放大,你不需要在CSS中修改任何东西。

完全响应,简单明了,非常容易管理。

<div class="Container">
    <div class="Header">
    </div>
    <div class="HeightTaker">
        <div class="Wrapper">
            <div class="LeftNavigation">
            </div>
            <div class="Content">
            </div>
        </div>
    </div>
</div>

Explanation: The container div takes 100% height of the body, and he's divided into 2 sections. The header section will span to its needed height, and the HeightTaker will take the rest. How is it achieved? by floating an empty element along side the container with 100% height (using :before), and giving the HeightTaker an empty element at the end with the clear rule (using :after). that element cant be in the same line with the floated element, so he's pushed till the end. which is exactly the 100% of the document.

这样,我们就可以让highttaker跨越容器高度的其余部分,而不需要声明任何特定的高度/边距。

在highttaker内部,我们建立了一个正常的浮动布局(以实现类似列的显示),并进行了微小的改变。我们有一个Wrapper元素,这是100%高度工作所需要的。

更新

下面是带有Bootstrap类的演示。(我只是在你的布局中添加了一个div)

你可以达到你想要的填充底部:100%;margin-bottom: -100%;戏法,你可以在这把小提琴上看到。

我稍微改变了你的HTML,但是你可以用下面的代码用你自己的HTML达到同样的结果

.col-md-9 {
    overflow: hidden;
}

.col-md-3 {
    padding-bottom: 100%;
    margin-bottom: -100%;
}

因此,你的最佳选择似乎是用负边际底部策略来对抗填充底部。

我举了两个例子。一个是<header>在.container内,另一个是<header>在.container外。

两个版本都可以正常工作。注意使用下面的@media查询,这样它就可以在较小的屏幕上删除额外的填充…

@media screen and (max-width:991px) {
    .content { padding-top:0; }
}

除此之外,这些例子应该可以解决您的问题。