首页 > bootstrap的container类的子div宽度(width:100%)不能占满?

bootstrap的container类的子div宽度(width:100%)不能占满?

最近在做一个个人的页面,使用到了bootstrap,可是在设置container类下面一个div的时候,该子div的宽度不能撑满父元素。
逻辑结构如下:

  <div class="container center-block">
    <div class="top">
      <img src="img/me.jpg" class="img-responsive img-circle myimg" id="myimg">
      <h1>heeefei</h1>
    </div>
    //其他的代码
  <.div>

.top的css设置如下:

.top {
    margin: 0;
    padding: 0;
    width: 100%;
    background-color: #00A6B6;
    text-align: center;
}

结果如下:白色的部分是.container,蓝色的部分是top,无论我怎么设置.top的css,都无法将去掉两边的白色带。
请问这是bootstrap的设置问题吗?在设置类名的时候不能用top类似的吗?还是说再container类里面就只能这样?


.container {
  margin-left: auto;
  margin-right: auto;
  padding-left: 15px;
  padding-right: 15px;
}

因为.container有内边距。


在你的div 加上一个父元素div class="row",或把你的div 设样式margin-left :-15px;margin-right:-15px;

【热门文章】
【热门文章】