如何使用bootstrap框架 bootstrap入門必看!
前言: 前幾天,本想做一個登陸界面,但自己寫form表單必然很丑,所以想用下bootstarp框架,之前聽別人說bootstrap很牛的樣子。但我完全不會bootstrap...
下載&目錄
看bootstrap官網(wǎng),接著我下載了用于生產(chǎn)環(huán)境Bootstrap:
解壓出來是這樣的:
目錄結(jié)構(gòu)大概是這樣的,前幾天在官網(wǎng)有看到。下面這個目錄結(jié)構(gòu)你應(yīng)該先了解下:
bootstrap3
├── css
│├── bootstrap-theme.css //主題類型,生產(chǎn)上一般用不到
│├── bootstrap-theme.css.map //主題類型,生產(chǎn)上一般用不到
│├── bootstrap-theme.min.css //主題類型,生產(chǎn)上一般用不到
│ ├── bootstrap.css
│ ├── bootstrap.css.map //做映射的,可以理解為 shuaige = “l(fā)uotianshuai” 那么掉shuaige的時候就相當于掉luotianshuai
│ └── bootstrap.min.css
├──fonts //包含了字體圖標文件,他也是做的對應(yīng)。下面的文件包含了不同系統(tǒng)下的字體圖標
│ ├── glyphicons-halflings-regular.eot
│ ├── glyphicons-halflings-regular.svg
│ ├── glyphicons-halflings-regular.ttf
│ ├── glyphicons-halflings-regular.woff
│ └── glyphicons-halflings-regular.woff2
└── js
├── bootstrap.js
├── bootstrap.min.js
bootstrap做了很多美化過的css樣式在bootstrap.css中,js則放在bootstrap.js。注意了,bootstrap的js與Jquery的js是不一樣的。bootstrap的js必須依賴Jquery。所以在導(dǎo)入JS的時候,得先導(dǎo)入Jquery.
應(yīng)用
接下來看官網(wǎng)給我們推薦的入門級模版.
雖然不怎么好看,但我想在本地上也能有這么個HTML文件。怎么搞??
右擊鼠標,點擊網(wǎng)頁另存為,保存到本地。
下載的除了HTML文件外,還有另外一個文件Starter Template for Boostrap_files,打開后,顯示如下:是所需要的bootstrap的css與js,可在HTML中引入。
我已經(jīng)下載了bootstrap,所以我直接用我本地的bootstrap就好了,于是我刪除上面的Starter Template for Boostrap_files文件夾。
bootstrap_1.html:
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 上述3個meta標簽*必須*放在最前面,任何其他內(nèi)容都*必須*跟隨其后! --> <title>Bootstrap 101 Template</title> <!-- Bootstrap --> <link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="stylesheet"> </head> <body> <h1>你好,世界!</h1> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="bootstrap-3.3.7-dist/js/jquery-3.1.1.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script> </body> </html>
- 11行從bootstrap導(dǎo)入css.
- 19行導(dǎo)入jquery
- 21行從bootstrap導(dǎo)入js
導(dǎo)入bootstrap的css與js注意路徑:
用瀏覽器打開上面的html界面會出現(xiàn)"你好,世界"。很low,我不禁懷疑bootstrap真的有用嗎??說好的美化效果呢
我在bootstrap官網(wǎng)隨便找下"巨幕"的組件
將組件的代碼貼到HTML的body中,便可以使用了。
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 上述3個meta標簽*必須*放在最前面,任何其他內(nèi)容都*必須*跟隨其后! --> <title>Bootstrap 101 Template</title> <!-- Bootstrap --> <link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="stylesheet"> </head> <body> <h1>你好,世界!</h1> <div class="jumbotron container"> <div > <h1>Hello, world!</h1> <p><a class="btn btn-primary btn-lg" href="#" rel="external nofollow" role="button">Learn more</a></p> </div> </div> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="bootstrap-3.3.7-dist/js/jquery-3.1.1.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script> </body> </html>
效果圖:
現(xiàn)在,你會使用bootstrap了吧,哈哈
建議好好看下官網(wǎng),我可是看了整個下午……都沒看完……
如果大家還想深入學(xué)習(xí),可以點擊這里進行學(xué)習(xí),再為大家附兩個精彩的專題:Bootstrap學(xué)習(xí)教程 Bootstrap實戰(zhàn)教程
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
全面解析JavaScript中apply和call以及bind(推薦)
在javascript中apply、call和bind是三兄弟,很好的搭檔,下面小編給大家全面解析JavaScript中apply和call以及bind的相關(guān)知識,感興趣的朋友一起學(xué)習(xí)吧2016-06-06JavaScript?Canvas實現(xiàn)圖片局部放大鏡效果
這篇文章主要為大家詳細介紹了如何使用JavaScript?Canvas實現(xiàn)圖片局部放大鏡效果,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-03-03學(xué)習(xí)JavaScript設(shè)計模式之模板方法模式
這篇文章主要為大家介紹了JavaScript設(shè)計模式中的模板方法模式,對JavaScript設(shè)計模式感興趣的小伙伴們可以參考一下2016-01-01學(xué)習(xí)JavaScript設(shè)計模式之迭代器模式
這篇文章主要為大家介紹了JavaScript設(shè)計模式中的迭代器模式,對JavaScript設(shè)計模式感興趣的小伙伴們可以參考一下2016-01-01Javascript延遲執(zhí)行實現(xiàn)方法(setTimeout)
延遲執(zhí)行,其實就是用到了setTimeout這個函數(shù)。善于利用這個函數(shù),可以減少很多ajax的請求,以及dom操作。2010-12-12