使用Bootstrap 3网格系统嵌套问题

时间:2017-09-04 06:49:11

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

我在.aspx页面中有以下代码

.cDiv {
  background-color: gray;
}

.tColor {
  background-color:yellow;
}

.tColor2 {
  background-color:blue;
}
<div class="container">
<div class="row">
    <div class="col-sm-9 tColor">
        Level 1: .col-sm-9
          <div class="row">
              <div class="col-sm-6 tColor2">
                  Level 2: .col-sm-6
              </div>
              <div class="col-sm-6 cDiv">
                  Level 2: .col-sm-6
              </div>
          </div>
      </div>
  </div>
</div>

问题是第二列比其父列宽。我得到以下结果

enter image description here

1 个答案:

答案 0 :(得分:0)

我想你忘了包含bootstrap css

.cDiv {
  background-color: gray;
}

.tColor {
  background-color:yellow;
}

.tColor2 {
  background-color:blue;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
    <div class="col-sm-9 tColor">
        Level 1: .col-sm-9
          <div class="row">
              <div class="col-sm-6 tColor2">
                  Level 2: .col-sm-6
              </div>
              <div class="col-sm-6 cDiv">
                  Level 2: .col-sm-6
              </div>
          </div>
      </div>
  </div>
</div>

工作Demo