Bootstrap Environment Setup
Installing Bootstrap is very easy. This chapter explains how to download and install Bootstrap, discusses the Bootstrap file structure, and demonstrates its usage through an example.
Download Bootstrap
You can download the jQuery EasyUI version you need from http://getbootstrap.com/ Download the latest version of Bootstrap from the site. When you click this link, you will see the page shown below:
You will see two buttons:
- Download Bootstrap: Download Bootstrap. Click this button to download a precompiled, minified version of Bootstrap CSS, JavaScript, and fonts. It does not include documentation or the original source files.
- Download Source: Download source code. Clicking this button lets you get the latest Bootstrap LESS and JavaScript source code directly from the source.
If you are using uncompiled source code, you need to compile the LESS files to generate reusable CSS files. For compiling LESS files, Bootstrap officially supports only RecessLess, which is Twitter's CSS preprocessor based on less.js Less.
For better understanding and more convenient use, we will use the precompiled version of Bootstrap in this tutorial.
Since the files are compiled and minified, you do not need to include these individual files every time in standalone feature development.
This tutorial was written using the latest version (Bootstrap 3).
File structure
Precompiled Bootstrap
When you download the compiled version of Bootstrap and unzip the ZIP file, you will see the following file/directory structure:
As shown above, you can see the compiled CSS and JS (bootstrap.), as well as the compiled and minified CSS and JS (bootstrap.min.). It also includes the Glyphicons fonts, which is an optional Bootstrap theme.
Bootstrap Source Code
If you download the Bootstrap source code, the file structure will look like this:
- less/、js/ and fonts/ The files under it are the source code for Bootstrap CSS, JS, and icon fonts, respectively.
- dist/ The folder contains the files and folders listed in the precompiled download section above.
- docs-assets/、examples/ and all the *.html files are Bootstrap documentation.
HTML Template
A basic HTML template using Bootstrap is shown below:
Example
<!DOCTYPE html><html>
<head>
<title>Bootstrap Template
title
<meta name="viewport" content=">width=device-width, initial-scale=1.0
"
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" head>
<body>
<h1>Hello, world!
h1
<script src="https://code.jquery.com/jquery.js" script>
<script src="js/bootstrap.min.js" script body html>Here you can see that it includes jquery.js、bootstrap.min.js and bootstrap.min.css files, which turn a regular HTML file into a Bootstrap-based template.
Details about each element in the code snippet above will be explained in Bootstrap CSS Overview chapter in detail.
Example
Now let's try using Bootstrap to output "Hello, world!":
Example
<
h1
Hello, world!
h1
Try it »
Staticfile CDN Recommendation
In China, it is recommended to use libraries on Staticfile CDN:
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js" script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js" script>Additionally, you can use the following CDN services:
- Internationally, it is recommended to use:https://cdnjs.com/