Home > Enterprise >  Bootstrap: Bootstrap Grid
Bootstrap: Bootstrap Grid

Time:10-04

I'm trying to use the Bootstrap Grid concept to create 12 columns in a single row, Instead of that I'm getting 12 rows in a container.

code that I have done

<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.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <title>document</title>
    <style>
        .box{
            background-color:aquamarine;
            border-style: solid;
            height: 100px;
        }
        .row{
            margin-top:10px;
        }
    </style>
</head>
<body>
    <div class="container-fluid jumbotron">
        <div class="container">
            <h2>BootStrap Grid</h2>
        </div>
    </div>

    <div class="container-fluid">
        <div class="row">
            <div class="col-1 box">1</div>
            <div class="col-1 box">2</div>
            <div class="col-1 box">3</div>
            <div class="col-1 box">4</div>
            <div class="col-1 box">5</div>
            <div class="col-1 box">6</div>
            <div class="col-1 box">7</div>
            <div class="col-1 box">8</div>
            <div class="col-1 box">9</div>
            <div class="col-1 box">10</div>
            <div class="col-1 box">11</div>
            <div class="col-1 box">12</div>
        </div>

    </div>
</body>
</html> 

Image of what I was getting

Image of what I should get

I'm new to Bootstrap, could anyone please solve my issue?

CodePudding user response:

Refer to the docs, for the version you are using the column classes all have a breakpoint.
Use:

<div class="col-xs-1 box">1</div>

Also, unrelated to the stated problem but, you have placed the bootstrap.js in the wrong location and omitted the required jquery script. They should be included just before the closing </body> tag as seen in the "getting started" template.

<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.0">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />

  <title>document</title>
  <style>
    .box {
      background-color: aquamarine;
      border-style: solid;
      height: 100px;
    }
    
    .row {
      margin-top: 10px;
    }
  </style>
</head>

<body>
  <div class="container-fluid jumbotron">
    <div class="container">
      <h2>BootStrap Grid</h2>
    </div>
  </div>

  <div class="container-fluid">
    <div class="row">
      <div class="col-xs-1 box">1</div>
      <div class="col-xs-1 box">2</div>
      <div class="col-xs-1 box">3</div>
      <div class="col-xs-1 box">4</div>
      <div class="col-xs-1 box">5</div>
      <div class="col-xs-1 box">6</div>
      <div class="col-xs-1 box">7</div>
      <div class="col-xs-1 box">8</div>
      <div class="col-xs-1 box">9</div>
      <div class="col-xs-1 box">10</div>
      <div class="col-xs-1 box">11</div>
      <div class="col-xs-1 box">12</div>
    </div>

  </div>

  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>

</html>

CodePudding user response:

// use this version -> [email protected]

  • Related