Alexandru Galamb
Alexandru Galamb

Reputation: 23

Twitter Bootstrap not displaying gutter

I am using twitter bootstrap 3 to create a website template, as far as I know it usually has a 15 px gutter on both sides at large display, I am not getting the gutter between divs.

    <!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>

Upvotes: 2

Views: 404

Answers (2)

Bariel R.
Bariel R.

Reputation: 173

Try putting the boxes inside the columns.

<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

Upvotes: 1

Boostrap rows have 15px negative left and right margins, and columns have 15px left and right padding respectively. You won't see a 'gutter' in the columns because of this fact. However, if you want to create a gutter-like effect, you can do this: Say you want a 2px gutter between each column. Add 1px to the column padding in addition to the 15px it needs.

CSS:

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

Do not add margins to the columns.

Upvotes: 0

Related Questions