Search code examples
twitter-bootstrapcol

Auto-layout columns is not working in Bootstrap


I tried to use the following code but it is not working. However, when I change the class "col" to "col-xs-4", all things are layouted as suspected.

https://v4-alpha.getbootstrap.com/layout/grid/#grid-options

 <div class="container">
      <div class="row">
        <div class="col">
          1 of 2
        </div>
        <div class="col">
          1 of 2
        </div>
      </div>
      <div class="row">
        <div class="col">
          1 of 3
        </div>
        <div class="col">
          1 of 3
        </div>
        <div class="col">
          1 of 3
        </div>
      </div>
    </div>

I am using the latest Bootstrap CDN.

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

Solution

  • You are linking to the Bootstrap v4 grid layout options but your stylesheet is using the Bootstrap v3.3.7 cdn. Adjust your <link rel> to the following:

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
    

    Here is a fiddle with this working (Note that on the left, we added the Bootstrap v4 CDN link

    https://fiddle.jshell.net/nLqwtw43/