Bootstrap Code Samples
Twitter Bootstrap makes life easy. If you are not much into designing layouts from pure CSS, twitter-bootstrap is ideal for you. Following shows some code samples that you might often need. Setting up bootstrap is trivial.
Setting-Up
- Download Bootstrap from http://getbootstrap.com/
- Unzip the folder. You may find following folders in it.
- Include these three folders in your Project folder.
- Add link to your index.html to bootstrap.css within in <head> tag as follows
<link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
- Add bootstrap script tags just above the </body> tag. Make sure you have jquery.js file
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
- That's it. To check if you have properly setup bootstrap, Write this line of code within the body section
<button class="btn btn-success">Test</button>
- Open up index.html in a browser. You should see green color Test button on the screen.
Nav-Bar Sample
Carousel Sample
Grid-System Sample
Setting-Up
- Download Bootstrap from http://getbootstrap.com/
- Unzip the folder. You may find following folders in it.
- Include these three folders in your Project folder.
- Add link to your index.html to bootstrap.css within in <head> tag as follows
<link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
- Add bootstrap script tags just above the </body> tag. Make sure you have jquery.js file
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
- That's it. To check if you have properly setup bootstrap, Write this line of code within the body section
<button class="btn btn-success">Test</button>
- Open up index.html in a browser. You should see green color Test button on the screen.
Nav-Bar Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Fixed Navigation Bar With Drop Down Menus --> | |
<div class="navbar navbar-default navbar-fixed-top "> | |
<div class="container"> | |
<div class="navbar-header"> | |
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-collapse"> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button> | |
<a href="#" class="navbar-brand">Manoj Enterprises</a> | |
</div> | |
<div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> | |
<li><a href="#">Home</a></li> | |
<li><a href="#">About</a></li> | |
<li class="dropdown"> | |
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Products <b class="caret"></b> </a> | |
<ul class="dropdown-menu"> | |
<li><a href="#">Dhamma Books</a></li> | |
<li><a href="#">Dayawnsa Publications</a></li> | |
<li><a href="#">Mahamevna Publications</a></li> | |
<li><a href="#">Newspapers</a></li> | |
<li><a href="#">Magazines</a></li> | |
</ul> | |
</li> | |
<li><a href="#">Contacts</a></li> | |
</ul> | |
</div> | |
</div> | |
</div> |
Carousel Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Carousel --> | |
<div id="this-carousel-id" class="carousel slide"><!-- class of slide for animation --> | |
<div class="carousel-inner"> | |
<div class="item active"><!-- class of active since it's the first item --> | |
<img src="http://placehold.it/1200x480" alt="" /> | |
<div class="carousel-caption"> | |
<p>Caption text here</p> | |
</div> | |
</div> | |
<div class="item"> | |
<img src="http://placehold.it/1200x480" alt="" /> | |
<div class="carousel-caption"> | |
<p>Caption text here</p> | |
</div> | |
</div> | |
<div class="item"> | |
<img src="http://placehold.it/1200x480" alt="" /> | |
<div class="carousel-caption"> | |
<p>Caption text here</p> | |
</div> | |
</div> | |
<div class="item"> | |
<img src="http://placehold.it/1200x480" alt="" /> | |
<div class="carousel-caption"> | |
<p>Caption text here</p> | |
</div> | |
</div> | |
</div><!-- /.carousel-inner --> | |
<!-- Next and Previous controls below | |
href values must reference the id for this carousel --> | |
<a class="carousel-control left" href="#this-carousel-id" data-slide="prev">‹</a> | |
<a class="carousel-control right" href="#this-carousel-id" data-slide="next">›</a> | |
</div><!-- /.carousel --> |
Grid-System Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row"> | |
<div class="col-md-8">.col-md-8</div> | |
<div class="col-md-4">.col-md-4</div> | |
</div> | |
<div class="row"> | |
<div class="col-md-4">.col-md-4</div> | |
<div class="col-md-4">.col-md-4</div> | |
<div class="col-md-4">.col-md-4</div> | |
</div> | |
<div class="row"> | |
<div class="col-md-6">.col-md-6</div> | |
<div class="col-md-6">.col-md-6</div> | |
</div> |
This comment has been removed by the author.
ReplyDelete