bootstrap使用模板

Bootstrap下载地址:

- https://github.com/twbs/bootstrap/releases/download/v3.3.6/bootstrap-3.3.6-dist.zip
- https://github.com/twbs/bootstrap/releases/download/v4.0.0-alpha.2/bootstrap-4.0.0-alpha.2-dist.zip

Bootstrap文档

- [官方文档](http://getbootstrap.com/)
- [中文文档](http://v3.bootcss.com/)

### 基础的Bootstrap模板

 1 ```html
 2 <!DOCTYPE html>
 3 <html lang="en">
 4 <head>
 5 <meta charset="utf-8">//设置文档编码方式
 6 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">//视口,确保移动端浏览器大小与视口一样
7 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 8 <meta name="viewport" content="width=device-width, initial-scale=1"> 9 <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 10 <title>Bootstrap 101 Template</title> 11 <!-- Bootstrap --> 12 <link href="css/bootstrap.min.css" rel="stylesheet"> 13 <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 14 <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 15 <!--[if lt IE 9]> 16 <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 17 <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 18 <![endif]--> 19 </head> 20 <body> 21 <h1>Hello, world!</h1> 22 <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 23 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 24 <!-- Include all compiled plugins (below), or include individual files as needed --> 25 <script src="js/bootstrap.min.js"></script> 26 </body> 27 </html> 28 ```

head内容详解:

1.

<meta http-equiv="X-UA-Compatible" content="IE=edge">
`
- 此属性为文档兼容模式声明,表示如果在IE浏览器下则使用最新的标准渲染当前文档

2.

<meta name="viewport" content="width=device-width, initial-scale=1">

- 视口的作用:在移动浏览器中,当页面宽度超出设备,浏览器内部虚拟的一个页面容器,将页面容器缩放到设备这么大,然后展示
- 目前大多数手机浏览器的视口(承载页面的容器)宽度都是980;
- 视口的宽度可以通过meta标签设置
- 此属性为移动端页面视口设置,当前值表示在移动端页面的宽度为设备的宽度,并且不缩放(缩放级别为1)
+ 视口的宽度
+ initial-scale:初始化缩放
+ user-scalable:是否允许用户自行缩放(值:yes/no; 1/0)
+ minimum-scale:最小缩放,一般设置了用户不允许缩放,就没必要设置最小和最大缩放
+ maximum-scale:最大缩放

3.

条件注释

- 条件注释的作用就是当判断条件满足时,就会执行注释中的HTML代码,不满足时会当做注释忽略掉

4.

第三方依赖

- [jQuery](https://github.com/jquery/jquery)

> Bootstrap框架中的所有JS组件都依赖于jQuery实现

- [html5shiv](https://github.com/aFarkas/html5shiv)

> 让低版本浏览器可以识别HTML5的新标签,如header、footer、section等

- [respond](https://github.com/scottjehl/Respond)

> 让低版本浏览器可以支持CSS媒体查询功能

原文地址:https://www.cnblogs.com/zmshare/p/6057429.html