如何理解Bootstrap3.0柵格系統(tǒng)

這篇文章主要介紹“如何理解Bootstrap3.0柵格系統(tǒng)”,在日常操作中,相信很多人在如何理解Bootstrap3.0柵格系統(tǒng)問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”如何理解Bootstrap3.0柵格系統(tǒng)”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比修武網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式修武網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋修武地區(qū)。費用合理售后完善,十年實體公司更值得信賴。

柵格系統(tǒng)(布局)

Bootstrap內(nèi)置了一套響應(yīng)式、移動設(shè)備優(yōu)先的流式柵格系統(tǒng),隨著屏幕設(shè)備或視口(viewport)尺寸的增加,系統(tǒng)會自動分為最多12列。

我在這里是把Bootstrap中的柵格系統(tǒng)叫做布局。它就是通過一系列的行(row)與列(column)的組合創(chuàng)建頁面布局,然后你的內(nèi)容就可以放入到你創(chuàng)建好的布局當(dāng)中。下面就簡單介紹一下Bootstrap柵格系統(tǒng)的工作原理:

行(row)必須包含在.container中,以便為其賦予合適的排列(aligment)和內(nèi)補(padding)。使用行(row)在水平方向創(chuàng)建一組列(column)。你的內(nèi)容應(yīng)當(dāng)放置于列(column)內(nèi),而且,只有列(column)可以作為行(row)的直接子元素。類似Predefined grid classes like .rowand .col-xs-4這些預(yù)定義的柵格class可以用來快速創(chuàng)建柵格布局。Bootstrap源碼中定義的mixin也可以用來創(chuàng)建語義化的布局。通過設(shè)置padding從而創(chuàng)建列(column)之間的間隔(gutter)。然后通過為第一和最后一樣設(shè)置負(fù)值的margin從而抵消掉padding的影響。柵格系統(tǒng)中的列是通過指定1到12的值來表示其跨越的范圍。例如,三個等寬的列可以使用三個.col-xs-4來創(chuàng)建。

DW6編碼實現(xiàn)

Okay勒,下面開始寫代碼了額。首先上一張圖看看我使用的編輯器,之前在學(xué)校學(xué)習(xí)Html+CSS的時候使用較多的工具。

如何理解Bootstrap3.0柵格系統(tǒng)

然后新建一個HTML文檔,選擇類型HTML5

如何理解Bootstrap3.0柵格系統(tǒng)

創(chuàng)建好后,另存為與上一節(jié)的講解中js、css文件夾的同一目錄下。

如何理解Bootstrap3.0柵格系統(tǒng)

layout.html就是我剛剛創(chuàng)建的文件。Bootstrap.html也是上一節(jié)中創(chuàng)建的第一個html頁面。

現(xiàn)在可以將Bootstrap.html中的代碼全部Copy到layout.html頁面。

然后在body標(biāo)簽下添加如下代碼

代碼如下:


<h2>Hello, world!</h2>
<h3 class="page-header">區(qū)域一</h3>
<p>Bootstrap has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.</p>
<h3 class="page-header">區(qū)域二</h3>
<p>If you work with Bootstrap's uncompiled source code, you need to compile the LESS files to produce usable CSS files. For compiling LESS files into CSS, we only officially support Recess, which is Twitter's CSS hinter based on less.js.</p>
<h3 class="page-header">區(qū)域三</h3>
<p>Within the download you'll find the following directories and files, logically grouping common resources and providing both compiled and minified variations.</p>

這幾個標(biāo)簽大家應(yīng)該都能看的明白,最基礎(chǔ)最簡單的。

添加完后layout.html頁面所有代碼如下

代碼如下:


<!DOCTYPE html>
<html>
<head>
<title>Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen"> <pre></pre> <pre><font face="Arial"><!-- HTML5 Shim and Respond.js 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="<a href="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script">https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script</a>>
<script src="<a href="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script">https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script</a>>
<![endif]-->
</head>
<body>
<h2>Hello, world!</h2>
<h3 class="page-header">區(qū)域一</h3>
<p>Bootstrap has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.</p>
<h3 class="page-header">區(qū)域二</h3>
<p>If you work with Bootstrap's uncompiled source code, you need to compile the LESS files to produce usable CSS files. For compiling LESS files into CSS, we only officially support Recess, which is Twitter's CSS hinter based on less.js.</p>
<h3 class="page-header">區(qū)域三</h3>
<p>Within the download you'll find the following directories and files, logically grouping common resources and providing both compiled and minified variations.</p> <script src="js/jquery-2.0.3.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

當(dāng)然效果也很簡單,我還是把截圖放上,可以進行對比。

如何理解Bootstrap3.0柵格系統(tǒng)

優(yōu)化一:可以發(fā)現(xiàn)上圖的頁面效果占滿全屏,我們可以通過Bootstrap 樣式類對上面的內(nèi)容進行居中。

代碼如下:


<div class="container"> .........之前上面添加在body標(biāo)簽下的代碼 </div>

效果如下

如何理解Bootstrap3.0柵格系統(tǒng)

可以發(fā)現(xiàn)container這個類設(shè)置了寬度,并且可以讓內(nèi)容顯示在頁面的中間。

優(yōu)化二:將三個區(qū)域顯示在同一排,并且平均分成三欄。

首先為三個區(qū)域添加一個容器,可以使用div,并且為div添加一個類 <div >.

然后我們?yōu)槊總€小的區(qū)域也添加一個容器div,并且為div添加一個類<div >

簡單代碼實現(xiàn)如下

代碼如下:


<div class="container"> <h2>Hello, world!</h2> <div class="row"> <div class="col-xs-4"> <h3 class="page-header">區(qū)域一</h3> <p>Bootstrap has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.</p> </div> <div class="col-xs-4"> <h3 class="page-header">區(qū)域二</h3> <p>If you work with Bootstrap's uncompiled source code, you need to compile the LESS files to produce usable CSS files. For compiling LESS files into CSS, we only officially support Recess, which is Twitter's CSS hinter based on less.js.</p> </div> <div class="col-xs-4"> <h3 class="page-header">區(qū)域三</h3> <p>Within the download you'll find the following directories and files, logically grouping common resources and providing both compiled and minified variations.</p> </div> </div> </div>

效果如下

如何理解Bootstrap3.0柵格系統(tǒng)

的確排成一列,然后分成三欄。再結(jié)合一下上面柵格系統(tǒng)的6部原理。是不是懂一點了,反正我自己懂了很多。通過同樣的方式可以創(chuàng)建出比較復(fù)雜的網(wǎng)格布局頁面。只需要在布局使用的容器上面添加相應(yīng)的網(wǎng)格布局的類。比如說如果內(nèi)容占用6個網(wǎng)格,那么就添加一個col-xs-6的類、占用四個網(wǎng)格就添加一個col-xs-4的類,然后在同一排的周圍進行使用帶有row類的容器。

到此,關(guān)于“如何理解Bootstrap3.0柵格系統(tǒng)”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

分享題目:如何理解Bootstrap3.0柵格系統(tǒng)
文章轉(zhuǎn)載:http://bm7419.com/article18/igsjdp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、關(guān)鍵詞優(yōu)化、微信公眾號網(wǎng)站內(nèi)鏈、網(wǎng)站改版、App開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)