欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Bootstrap3.0學(xué)習(xí)筆記之柵格系統(tǒng)原理

  發(fā)布時間:2014-11-19 14:29:49   作者:佚名   我要評論
本文主要介紹了Bootstrap內(nèi)置了一套響應(yīng)式、移動設(shè)備優(yōu)先的流式柵格系統(tǒng),它就是通過一系列的行(row)與列(column)的組合創(chuàng)建頁面布局,然后你的內(nèi)容就可以放入到你創(chuàng)建好的布局當(dāng)中。下面就簡單介紹一下Bootstrap柵格系統(tǒng)的工作原理

通過前面兩篇文章的簡單介紹,大致對于Bootstrap有了初步的了解。由于自己也只是想通過Bootstrap官網(wǎng)來進(jìn)行簡單的學(xué)習(xí),自己能夠隨便搞個不是太搓的頁面就可以了。所以如果你是新手或許可以來看看,對你還有那么一點(diǎn)兒幫助,高手請飄過。

《Bootstrap3.0學(xué)習(xí)筆記》中也只是簡單的介紹了如何下載文件,及進(jìn)行引用下載的文件,還沒有真正的進(jìn)入前端的設(shè)計學(xué)習(xí)中。我也看到了廣大網(wǎng)友們對Bootstrap3.0也具有很大的興趣,有之前就使用過的大牛,也有和我一樣正打算學(xué)習(xí)一下的盆友、小菜。至于回復(fù)中比較多的就是:希望能有個系列,當(dāng)然我也很希望自己能很好的規(guī)劃列一個系列,然后按照這個大綱進(jìn)行即可。不過本人能力有限,所以只好跟隨自己的喜好來進(jìn)行學(xué)習(xí)了。

聲明:寫作能力真是不濟(jì),還望各位看官見諒。如有錯誤,請及時通知,本人必會在最短的時間進(jìn)行更正,當(dāng)然更希望能有更多的人來一起學(xué)習(xí)。

柵格系統(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)補(bǔ)(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編碼實(shí)現(xiàn)

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

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

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

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

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

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


復(fù)制代碼
代碼如下:

<h1>Hello, world!</h1>
<h2 class="page-header">區(qū)域一</h2>
<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>
<h2 class="page-header">區(qū)域二</h2>
<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>
<h2 class="page-header">區(qū)域三</h2>
<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頁面所有代碼如下


復(fù)制代碼
代碼如下:

<!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 ></script</a>>
<script src="<a ></script</a>>
<![endif]-->
</head>
<body>
<h1>Hello, world!</h1>
<h2 class="page-header">區(qū)域一</h2>
<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>
<h2 class="page-header">區(qū)域二</h2>
<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>
<h2 class="page-header">區(qū)域三</h2>
<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)然效果也很簡單,我還是把截圖放上,可以進(jìn)行對比。

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


復(fù)制代碼
代碼如下:

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

效果如下

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

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

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

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

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


復(fù)制代碼
代碼如下:

<div class="container"> <h1>Hello, world!</h1> <div class="row"> <div class="col-xs-4"> <h2 class="page-header">區(qū)域一</h2> <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"> <h2 class="page-header">區(qū)域二</h2> <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"> <h2 class="page-header">區(qū)域三</h2> <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>

效果如下

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

總結(jié)

本節(jié)主要學(xué)習(xí)的布局(柵格系統(tǒng)),通過簡單的實(shí)例來理解它的工作原理。

使用過的類有:

1..container:用.container包裹頁面上的內(nèi)容即可實(shí)現(xiàn)居中對齊。在不同的媒體查詢或值范圍內(nèi)都為container設(shè)置了max-width,用以匹配柵格系統(tǒng)。

2..col-xs-4:這個類通過"-"分為三個部分,第三個部分的數(shù)字作為一個泛指,它的范圍是1到12。就是可以把一個區(qū)域分為12個欄,這個要和row類聯(lián)合使用。

其實(shí)這個布局很像HTMl中的Table布局TR行和TD列吧。

暫時的理解就這些,代碼直接復(fù)制粘貼就可以看效果,當(dāng)然首先要把預(yù)先的css、js文件進(jìn)行準(zhǔn)備。

相關(guān)文章

最新評論