Bootstrap - 全宽布局两列,具有不同的颜色

时间:2015-09-23 11:14:37

标签: css twitter-bootstrap twitter-bootstrap-3

我的问题在于我无法通过背景着色来解决问题。左列总是出血#39;进入右栏的顶部。 帮帮我们,我现在试着修三天。

这是我的HTML代码:

<div class="container-fluid">
    <div class="row blue-background">
        <div class="col-lg-6 col-xs-12 col-lg-offset-1">
            <h1>Text here</h1>
        </div>
        <div class="col-lg-5 col-xs-12 gray-background">
            <h2>Another text here</h2>
        </div>
    </div><!--  .row -->
</div><!--  .container-fluid -->

在我的自定义CSS文件中,这个类只有background:/ value_of_color /

我的CSS代码:

.blue-background {
    background-color: blue;
}

.gray-background {
    background-color: #eaeaea;
}

2 个答案:

答案 0 :(得分:0)

<div class="container-fluid">
    <div class="row ">
        <div class="col-lg-6 col-xs-12 col-lg-offset-1 blue-background">
            <h1>Text here</h1>
        </div>
        <div class="col-lg-5 col-xs-12 gray-background">
            <h2>Another text here</h2>
        </div>
    </div><!--  .row -->
</div><!--  .container-fluid -->

答案 1 :(得分:0)

你可以这样试试 -

.blue-background {
    background-color: blue;
}
.blue-background:after{
  content:'';
  display:block;
  clear:both;
}

.gray-background {
    background-color: #eaeaea;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
    <div class="row">
      <div class="blue-background">
        <div class="col-lg-6 col-xs-12 col-lg-offset-1">
              <h1>Text here</h1>
          </div>
          <div class="col-lg-5 col-xs-12 gray-background">
              <h2>Another text here</h2>
          </div>
      </div>
    </div><!--  .row -->
</div><!--  .container-fluid -->

我希望它会对你有所帮助。