开发者社区> 问答> 正文

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类里面就只能这样?

screenshot

展开
收起
杨冬芳 2016-06-06 14:54:53 5930 0
1 条回答
写回答
取消 提交回答
  • IT从业

    素div class="row",或把你的div 设样式margin-left :-15px;margin-right:-15px;

    2019-07-17 19:28:39
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载