Bootstrap入門(mén)教程一Hello Bootstrap初識(shí)
一、Bootstrap簡(jiǎn)介
Bootstrap,來(lái)自 Twitter,是目前很受歡迎的前端框架。Bootstrap是基于 HTML5、CSS3和Javascriopt開(kāi)發(fā)的,它在 jQuery的基礎(chǔ)上進(jìn)行了更為個(gè)性化和人性化的完善,形成一套自己獨(dú)有的網(wǎng)站風(fēng)格,并兼容大部分jQuery插件,為實(shí)現(xiàn)快速開(kāi)發(fā)提供了一套前端工具包,包括豐富的布局、柵格、豐富的Web組件和jQuery插件等,并能通過(guò)Less進(jìn)行樣式定制。
二、Hello Bootstrap
1.建立項(xiàng)目目錄結(jié)構(gòu),新建app、css、font、img和js目錄,其中app存放angular相關(guān)子模板和控制器。向css目錄中拷貝入ie10-viewport-bug-workaround.css,向js目錄中拷貝入ie8-responsive-file-warning.js、ie-emulation-modes-warning.js和ie10-viewport-bug-workaround.js,這幾個(gè)文件是讓bootstrap在ie瀏覽器中針對(duì)ie的兼容性做的優(yōu)化。
?
2.新建index.html頁(yè)面,在中引入bootstrap.css及兼容ie的css:
3.在底部依次引入jquery.js、bootstrap.js及兼容ie的js:
?
4.編寫(xiě)頁(yè)面內(nèi)容,先在標(biāo)簽下加入<div class="container"></div>,然后在其中插入具體頁(yè)面代碼,本例包括頂部導(dǎo)航和一個(gè),完整代碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content="Mac.Manon"> <link rel="icon" href="../../favicon.ico"> <title>Hello Bootstrap</title> <!-- 引入Bootstrap樣式 --> <link href="node_modules/bootstrap/dist/css/bootstrap.css" rel="stylesheet"> <!--對(duì)IE特定版本的兼容性處理 開(kāi)始--> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet"> <!-- Just for debugging purposes. Don‘t actually copy these 2 lines! --> <!--[if lt IE 9]><script src="js/ie8-responsive-file-warning.js"></script><![endif]--> <script src="js/ie-emulation-modes-warning.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[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]--> <!--對(duì)IE特定版本的兼容性處理 結(jié)束--> <!-- 本模版專(zhuān)用相關(guān)樣式 --> <link href="css/navbar.css" rel="stylesheet"> </head> <body> <!--container容器 開(kāi)始--> <div class="container"> <!-- 導(dǎo)航 開(kāi)始 --> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Buyinplay</a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li><a href="#">Something else here</a></li> <li role="separator" class="divider"></li> <li class="dropdown-header">Nav header</li> <li><a href="#">Separated link</a></li> <li><a href="#">One more separated link</a></li> </ul> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li class="active"><a href="./">Default <span class="sr-only">(current)</span></a></li> <li><a href="../navbar-static-top/">Static top</a></li> <li><a href="../navbar-fixed-top/">Fixed top</a></li> </ul> </div><!--/.nav-collapse --> </div><!--/.container-fluid --> </nav> <!--導(dǎo)航 結(jié)束--> <!-- 正文 開(kāi)始 --> <div class="jumbotron"> <h1>Hello Bootstrap !</h1> <p>This example is a quick exercise to illustrate how the default, static navbar and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p> <p> <a class="btn btn-lg btn-primary" href="../../components/#navbar" role="button">View detail docs »</a> </p> </div> <!--正文 結(jié)束--> </div> <!--container容器 結(jié)束--> <!--引用js資源 開(kāi)始--> <script src="node_modules/jquery/dist/jquery.js"></script> <script src="node_modules/bootstrap/dist/js/bootstrap.js"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <script src="js/ie10-viewport-bug-workaround.js"></script> <!--引用js資源 結(jié)束--> </body> </html>
效果如下:
三、參考資源
官網(wǎng):http://getbootstrap.com
官網(wǎng)中文站: http://www.bootcss.com
教程資源:http://www.runoob.com/bootstrap/bootstrap-page-header.html
以上所述是小編給大家介紹的Bootstrap入門(mén)教程一Hello Bootstrap初識(shí),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
JavaScript實(shí)現(xiàn)簡(jiǎn)單的雙色球(實(shí)例講解)
下面小編就為大家?guī)?lái)一篇JavaScript實(shí)現(xiàn)簡(jiǎn)單的雙色球(實(shí)例講解)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-07-07JavaScript實(shí)現(xiàn)拼圖式滑塊驗(yàn)證功能
滑塊驗(yàn)證碼是在網(wǎng)站、APP等應(yīng)用中常見(jiàn)的一種驗(yàn)證方式,通過(guò)按照一定規(guī)則滑動(dòng)滑塊到指定位置完成驗(yàn)證,才可以進(jìn)行下一步操作,本文給大家分享基于JavaScript實(shí)現(xiàn)拼圖式滑塊驗(yàn)證功能,感興趣的朋友一起看看吧2022-06-06Bootstrap每天必學(xué)之簡(jiǎn)單入門(mén)
相信大家閱讀了Bootstrap第一篇文章后,對(duì)Bootstrap充滿了探索欲望,小編也對(duì)Bootstrap產(chǎn)生了興趣,所以今天再整理一篇關(guān)于Bootstrap的入門(mén)介紹,希望大家喜歡。2015-11-11微信小程序提取公用函數(shù)到util.js及使用方法示例
這篇文章主要介紹了微信小程序提取公用函數(shù)到util.js及使用方法,結(jié)合實(shí)例形式分析了util.js公用函數(shù)相關(guān)調(diào)用操作技巧,需要的朋友可以參考下2019-01-01JavaScript 加號(hào)(+)運(yùn)算符號(hào)
在一些框架中看到了類(lèi)似這樣的寫(xiě)法:+new Date();感覺(jué)有些怪,查閱了相關(guān)資料和一些網(wǎng)友的幫助.對(duì)此用法解釋如下,希望對(duì)大家有所幫助,不合適的地方請(qǐng)大家指正!2009-12-12JavaScript中json數(shù)組查找數(shù)據(jù)的幾種方式(含模糊查找)
這篇文章主要給大家介紹了關(guān)于JavaScript中json數(shù)組查找數(shù)據(jù)的幾種方式,文中包括模糊查找,文中給出了詳細(xì)的代碼示例,對(duì)大家學(xué)習(xí)或者使用json具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-09-09layui 數(shù)據(jù)表格 點(diǎn)擊分頁(yè)按鈕 監(jiān)聽(tīng)事件的實(shí)例
今天小編就為大家分享一篇layui 數(shù)據(jù)表格 點(diǎn)擊分頁(yè)按鈕 監(jiān)聽(tīng)事件的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09