一、什么是Bootstrap?
- 框架:庫(kù) lib library
- jQuery作為一個(gè)框架來(lái)講,提供一套比較便捷的操作DOM的方式
- 把大家都需要的功能預(yù)先寫好到一些文件 這就是一個(gè)框架
- Bootstrap 讓我們的 Web 開發(fā)更簡(jiǎn)單,更快捷;
- 注意是 Bootstrap 不是 BootStrap!這是一個(gè)詞,不是合成詞,其含義為:n. 引導(dǎo)指令,引導(dǎo)程序
- Bootstrap 是當(dāng)下最流行的前端框架(界面工具集);
- 特點(diǎn)就是靈活簡(jiǎn)潔,代碼優(yōu)雅,美觀大方;
- 其目的是為了讓 Web 開發(fā)更敏捷;
- 是 Twitter 公司的兩名前端工程師 Mark Otto 和 Jacob Thornton 在 2011 - 年發(fā)起的,并利用業(yè)余時(shí)間完成第一個(gè)版本的開發(fā);
二、為什么使用Bootstarp?
- 生態(tài)圈火,不斷地更新迭代;
- 提供一套美觀大方地界面組件;
- 提供一套優(yōu)雅的 HTML+CSS 編碼規(guī)范;
- 讓我們的 Web 開發(fā)更簡(jiǎn)單,更快捷;
注意:使用 Bootstrap 并不代表不用寫 CSS 樣式,而是不用寫絕大多數(shù)大家都會(huì)用到的樣式
三、下載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
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>頁(yè)面標(biāo)題</title>
<!-- 引入Bootstrap核心樣式文件(必須) -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- 引入Bootstrap默認(rèn)主題樣式(可選) -->
<link rel="stylesheet" href="css/bootstrap.theme.min.css">
<!-- 你自己的樣式或其他文件 -->
<link rel="stylesheet" href="example.css">
</head>
<body>
<!-- 你的HTML結(jié)構(gòu)...... -->
<!-- 以下代碼,如果不使用JS插件則不需要 -->
<!-- 由于Bootstrap的JS插件依賴jQuery,so 引入jQuery -->
<script src="js/jquery.min.js"></script>
<!-- 引入所有的Bootstrap的JS插件 -->
<script src="bootstrap.min.js"></script>
<!-- 你自己的腳本文件 -->
<script src="my.js"></script>
</body>
</html>
五、Bootstrap文檔
六、基礎(chǔ)的Bootstrap模板
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<h1>Hello, world!</h1>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
- Compatible
此屬性為文檔兼容模式聲明,表示如果在IE瀏覽器下則使用最新的標(biāo)準(zhǔn)渲染當(dāng)前文檔
<meta http-equiv="X-UA-Compatible" content="IE=edge">
- 視口
在移動(dòng)瀏覽器中,當(dāng)頁(yè)面寬度超出設(shè)備,瀏覽器內(nèi)部虛擬的一個(gè)頁(yè)面容器,將頁(yè)面容器縮放到設(shè)備大小,然后展示;
<meta name="viewport" content="width=device-width, initial-scale=1">
- 條件注釋
條件注釋的作用就是當(dāng)判斷條件滿足時(shí),就會(huì)執(zhí)行注釋中的HTML代碼,不滿足時(shí)會(huì)當(dāng)做注釋忽略掉;
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
-
第三方依賴
媒體查詢
@media (判斷條件(針對(duì)于當(dāng)前窗口的判斷)){
/*這里的代碼只有當(dāng)判斷條件滿足時(shí)才會(huì)執(zhí)行*/
}
@media (min-width: 768px) and (max-width: 992px) {
.container {
width: 750px;
}
}
當(dāng)使用min-width作為判斷條件一定要從小到大,其原因是CSS從上往下執(zhí)行;反之,max-width是從大到小。
七、基礎(chǔ)CSS樣式
- 統(tǒng)一預(yù)制標(biāo)簽樣式
- 按鈕樣式
- 表格樣式
- 表單樣式
- 圖片樣式
- 輔助工具類
- 代碼樣式
-
柵格系統(tǒng)
- col-xs : 超小屏幕 手機(jī) (<768px)
- col-sm : 小屏幕 平板 (≥768px)
- col-md : 中等屏幕 桌面顯示器 (≥992px)
- col-lg : 大屏幕 大桌面顯示器 (≥1200px)
-
響應(yīng)式工具類
- hidden-xx-* : 在某種屏幕下隱藏
- visible-xx-* : 在某種屏幕尺寸下顯示
八、預(yù)置界面組件
- 導(dǎo)航
- 導(dǎo)航條
- 路徑導(dǎo)航(面包屑導(dǎo)航)
- 下拉菜單
- 按鈕式下拉菜單
- 按鈕組
- 輸入框組
- 警告框
- 頁(yè)頭
- 分頁(yè)
- 列表組
- 面板
- 媒體對(duì)象
- 進(jìn)度條
- Glyphicons字體圖標(biāo)
- 標(biāo)簽
- 徽章
- 縮略圖
- 巨幕
- 嵌入內(nèi)容
- Well內(nèi)嵌