codecamp

Bootstrap 安装

在本教程中,我们将学习如何使用Twitter Bootstrap v3.0编译版本创建一个基本的Bootstrap模板。

下载引导程序文件

Bootstrap有两个版本可供下载,编译的Bootstrap和Bootstrap源文件。

编译下载包含CSS和JavaScript文件的编译和缩小版本以及字体格式的图标,用于更快的Web开发

源版本包含所有CSS和JavaScript的原始源文件,以及文档的本地副本。

我们将使用编译的Bootstrap文件。 这里是下载链接。

http://getbootstrap.com/

文件结构

一旦下载编译的Bootstrap,解压缩压缩文件夹。你将找到以下文件结构和内容。

bootstrap/
    +-- css/
    |   +-- bootstrap.css
    |   |-- bootstrap.min.css
    |   |-- bootstrap-theme.css
    |   |-- bootstrap-theme.min.css
    +-- js/
    |   |-- bootstrap.js
    |   |-- bootstrap.min.js
    +-- fonts/
        |-- glyphicons-halflings-regular.eot
        |-- glyphicons-halflings-regular.svg
        |-- glyphicons-halflings-regular.ttf
        |-- glyphicons-halflings-regular.woff

Bootstrap的编译版本提供了编译的CSS和JS文件(bootstrap.*),以及编译和缩小CSS和JS(bootstrap.min.*)。

在fonts文件夹中有四个字体文件(glyphicons-halflings-regular.*)。这些字体文件包括Glyphicon Halflings集中的200个图标。

请注意,所有JavaScript插件都需要包含jQuery。

使用Bootstrap创建Web页面

打开代码编辑器并创建一个新的HTML文件,如下。

<!DOCTYPE html>
<html>
<head>
<title>Basic HTML File</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
    <h1>Hello, world! W3Cschool !</h1>
</body>
</html>

要使此HTML文件成为Bootstrap模板,需包括相应的Bootstrap CSS和JS文件。

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Basic Bootstrap Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
</head>
<body>
    <h1>Hello, world! W3Cschool !</h1>    <script src="http://code.jquery.com/jquery.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
</body>
</html>
我们在页面底部包含JavaScript文件 - 在关闭<body>标签(即</body>)之前,以提高网页的性能。
注意css和Javascript的相对路径。

Staticfile CDN 推荐

国内推荐使用 Staticfile CDN 上的库:

<!-- 新 Bootstrap 核心 CSS 文件 -->
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
 
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
 
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>


Bootstrap 网格系统
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Bootstrap 介绍

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }