Twitter Bootstrap 不显示装订线

Twitter Bootstrap not displaying gutter

我正在使用 twitter bootstrap 3 创建一个网站模板,据我所知,它通常在大型显示器的两侧都有一个 15 像素的装订线,我没有得到 div 之间的装订线。

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<h1>Hello, world!</h1>
<div class="container">
    <div class="row">
<div class="col-lg-3" style="background-color:red; height: 80px;">test</div>
<div class="col-lg-3" style="background-color:red; height: 80px;">test</div>
<div class="col-lg-3" style="background-color:red; height: 80px;">test</div>
<div class="col-lg-3" style="background-color:red; height: 80px;">test</div>
    </div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>

Boostrap 行有 15px 左右负边距 margins,列分别有 15px 左右 padding。因此,您不会在列中看到 'gutter'。然而,如果你想创建一个类似装订线的效果,你可以这样做:假设你想要在每列之间有一个 2px 的装订线。除了所需的 15 像素外,还向列填充添加 1 像素。

CSS:

div.col-lg-3 {
  padding-left: 16px; // gutter / 2
  padding-right: 16px; // gutter / 2
}

不要在列中添加边距。

尝试将方框放在列内。

<div class="container">
    <div class="row">
        <div class="col-lg-3">
            <div style="background-color:red; height: 80px;">test</div>
        </div>
        <div class="col-lg-3">
            <div style="background-color:red; height: 80px;">test</div>
        </div>
        <div class="col-lg-3">
            <div style="background-color:red; height: 80px;">test</div>
        </div>
        <div class="col-lg-3">
            <div style="background-color:red; height: 80px;">test</div>
        </div>
    </div>
</div>

JSFiddle