Learner
Learner

Reputation: 21445

Basic Bootstrap not working

I am trying to learn Bootstrap following this Orielly Bootstrap book.

This is the simple html code:

<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
<h1>Hello, world!</h1>
<script src="js/bootstrap.min.js"></script>
<div class="row">
    <div class="span8">Span 8</div>
    <div class="span4">Span 4</div>
</div>
</body>
</html>

I have downloaded Bootstrap and I have bootstrap.css and bootstrap.min.js at correct places. As per the code, we should get a row with 2 columns. But I am getting output as :

enter image description here

Please let me know what is the correct way of doing this?

Upvotes: 0

Views: 49

Answers (4)

MD Ashik
MD Ashik

Reputation: 9845

You need to call a class in div container/container-fluid .

Demo HTML5 + Bootstrap + Font Awesome Template source LINK

<div class="container">
  <div class="col-md-12">
      <h1>Hello, world!</h1>
      <div class="row">
          <div class="span8">Span 8</div>
          <div class="span4">Span 4</div>
      </div>
  </div>
</div>

Live link

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <div class="col-md-12">
      <h1>Hello, world!</h1>
      <div class="row">
          <div class="span8">Span 8</div>
          <div class="span4">Span 4</div>
      </div>
  </div>
</div>

Upvotes: 0

Martin Jinda
Martin Jinda

Reputation: 488

You are using old syntax of Bootstrap 2. Let's switch to BS3 or 4.

For a basic thing (testing, playing, whatever). I would recommend to use CDN source for Bootstrap. And get through to all documentation.

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>

Upvotes: 0

Pranjal
Pranjal

Reputation: 1128

Also added the viewport meta required for bootstrap

<!DOCTYPE html>
<html>
<head>
<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.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

 </head>

<body>
     <h1>Hello, world!</h1>
<div class="row">
    <div class="col-md-8">Span 8</div>
    <div class="col-md-4">Span 4</div>
</div>


 </body>

</html>

Upvotes: 1

Quentin
Quentin

Reputation: 944480

class="span8"

It looks like the book you are reading is out of date. That is the syntax used in Bootstrap 2 (which is no longer supported).

Presumably you have downloaded the CSS for Bootstrap 3 or 4. Consult their documentation for the current syntax, which has changed significantly since Bootstrap 2.

Upvotes: 1

Related Questions