css - 为什么在这个html页面中有水平滚动条

标签 css html twitter-bootstrap-3

链接:http://codepen.io/anon/pen/KVMNzP

body {
  font-family: Consolas, Sans;
}
.spacer {
  height:100px;
}
#firstDiv {
  height:300px;
}
.row-eq-height {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}
.nopadding {
  padding:0;
  margin:0;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
      <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  </head>
  <body>
    <div class="spacer"></div>
    <div id="firstDiv" class="row row-eq-height" style="background-color:#ddaaee;">
      <div class="col-xs-12 col-sm-4 nopadding" style="background-color:#45aa78;">
        Col1
      </div>
      <div class="col-xs-12 col-sm-4 nopadding" style="background-color:#ccaa78;">
        Col2
      </div>
      <div class="col-xs-12 col-sm-4 nopadding" style="background-color:#45aa2b;">
        <div class="list-group">
          <a href="#" class="list-group-item">List Item 1</a>
          <a href="#" class="list-group-item">List Item 2</a>
          <a href="#" class="list-group-item">List Item 3</a>
          <a href="#" class="list-group-item">List Item 4</a>
        </div>
      </div>
    </div>
  </body>
</html>

我认为整个内容应该完全适合屏幕。 我不希望在这种情况下出现单杠,我还希望列表组适合第三列而没有任何填充。

请提出代码更改建议,或指出我可能犯的任何错误。

最佳答案

根据您想要实现的目标,您应该使用容器,即 containercontainer-fluid,它们应该位于行的外部。

其他答案部分正确,因为它们正在改变 Bootstrap 的工作方式。

基本布局应该是这样的:

<div class="container">
   <div class="row">
      <div class="col-xs-12"></div>
   </div>
</div>

关于css - 为什么在这个html页面中有水平滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34396231/

相关文章:

javascript - 使文本字段根据窗口宽度适当调整大小

html - 在新行中显示 Bootstrap 折叠导航栏

css - Bootstrap 3 列 100% 高度减去标题

javascript - 光标 :pointer not working on input type file

html - 如何在没有伪类、JS 或 <tr> 类的情况下设置备用表行的样式

javascript - 获取关闭模态的元素

javascript - JQuery 选择器 : Apply rule to element when certain child is NOT clicked

html - CSS 布局 z-index 居中

javascript - 有没有办法让 div 从展开的 div 左右浮动?

html - Div 高度未完全拉伸(stretch)到 100%