【问题标题】:Bootstrap - Make a column 100% the height of the rowBootstrap - 使列的高度为行高的 100%
【发布时间】:2015-05-20 13:31:33
【问题描述】:

我有一行包含两列,我希望该行中的两个单元格具有相同的高度。在屏幕截图中,左侧单元格小于右侧单元格,因此我希望它与行的高度相同。问题是任何一个单元格都可能比它的邻居大。

用蓝线表示应该在哪里组成空间的示例:

该行的sn-p为:

<div class="row center-block">
    <div class="col-sm-4">
        <div class="well-menu">
            <ul class="nav">
                <li>
                    <a title="Home" href="/">Home</a>
                </li>
                <li>
                    <a title="Contact" href="#">Contact</a>
                </li>
                <li>
                    <a title="Parent Portal" href="#">Parent Portal</a>
                </li>
            </ul>
        </div>
    </div>
    <div class="visible-xs-block padding-top-10"></div>
    <div class="col-sm-8">
        <div id="subscribe-box" class="well-menu">
            <form action="#">
                <div class="input-group">
                    <h3>Subscribe to our newsletter:</h3>
                    <input class="btn btn-lg" name="email" id="email" type="email" placeholder="Your Email" required>
                    <button class="btn btn-info btn-lg" type="submit">Submit</button>
                </div>
            </form>
        </div>
    </div>
</div>

样式:

.well-menu {
  padding: 0 18px;
  line-height: 42px;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 7px;
  background-clip: padding-box;
  box-shadow: 0 1px 0px rgba(255, 255, 255, 0.2), inset 0 1px 0 rgba(0, 0, 0, 0.5);
}
.well-menu>.nav>li {
  float: left;
  margin: 0;
}
.well-menu>.nav>li:first-child>a{
  margin: 0 10px 0 0;
}
.well-menu>.nav>li:last-child>a{
  margin: 0 0 0 10px;
}
.well-menu>.nav>li>a{
  position: relative;
  display: inline;
  color: #DBDDDD;
  padding: 0;
  margin: 0 10px;
  background: transparent;
}
.well-menu > .nav > li > a:hover{
  color: #fff;
  text-decoration: none;
}
.well-menu>.nav>li:not(:first-child):before{
  display: inline-block;
  content: "\2022";
  float: left;
  margin: 0 2px;
  color:#DBDDDD !important;
}

【问题讨论】:

标签: html css twitter-bootstrap multiple-columns


【解决方案1】:

我认为 bootstrap 有一个 row-eq-height 类,您可以将其添加到这两列的包含 div 中。

编辑:这是一个链接

http://getbootstrap.com.vn/examples/equal-height-columns/

【讨论】:

  • 由于某种原因没有奏效,但我已经更新了我的问题并添加了一些 CSS 以查看是否更清楚我的问题是什么。
  • 另外我只提一下...我确定为您的项目更改框架是不现实的,但如果有可能,我会使用 Foundation 框架而不是 Bootstrap .它有一个“均衡器”来处理这个确切的问题。
【解决方案2】:

使 BootStrap Column 成为行的 100% 高度

将以下代码添加到该部分:

 .row {
    display: table;
 }

.row [class*="col-"] {
    float: none;
    display: table-cell;
    vertical-align: top;
}

这是一个重复的问题,我想感谢 popnoodles 教我如何做到这一点。 希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-08
    • 2017-05-17
    相关资源
    最近更新 更多