标签:bsp 入门教程 common 学习 overflow ase body des 介绍
Bootstrap建立了一个响应式的12列格网布局系统,它引入了fixed和fluid-with两种布局方式。我们从全局样式(Global Style),格网系统(Grid System),流式格网(Fluid grid System),自定义(Customing),布局(Layouts),响应式设计(Responsive Design)这六五个方面深入讲解Boostrap的scaffolding.
<!DOCTYPE html> <html lang="en"> ... </html>
<div class="row"> <div class="span4">...</div> <div class="span8">...</div> </div>
2.2 偏移列. 有时候,页面要素前面需要一些空白,bootstrap提供了偏移列来实现,如图1-2所示:
图1-2 偏移列(Offset columns)
以下代码实现了是实现图1-2中,第一列的宽度为4和偏移度为4宽度为4的两个div.
<div class="row"> <div class="span4">...</div> <div class="span4 offset4">...</div> </div>
2.3 嵌套列. 嵌套列是容许用户实现更复杂的页面要素布局。在bootstrap中实现嵌套列非常简单,只需要在原有的div中加入.row 和相应的长度的span* div即可。 如图1-3所示:
以下代码实现了是实现图1-3中,第一层的宽度为12和第二层两个宽度为6的两个div.
<div class="row"> <div class="span12"> Level 1 of column <div class="row"> <div class="span6">Level 2</div> <div class="span6">Level 2</div> </div> </div> </div>
嵌套的div长度之和不能大于它的父div,否则会溢出叠加。各位可以试试将第一层的div长度改为其他值,看看效果。
<div class="row-fluid"> <div class="span4">...</div> <div class="span8">...</div> </div>
嵌套的流式格网和嵌套的固定格网,稍微有些不同。嵌套流式格网(Fluid nesting)的子要素不用匹配父要素的宽度,子要素用100%来表示占满父要素的页面宽度。
变量 | 默认值 | 说明 |
---|---|---|
@gridColumns |
12 | 列数 |
@gridColumnWidth |
60px | 每列的宽度 |
@gridGutterWidth |
20px | 列间距 |
表1-1 格网变量 我们通过修改以上值,并重新编译Bootstrap来实现自定义格网系统。如果添加新的列,需要同时修改grid.less.同样的,需要修改responsive.less来获得多设备兼容.
<body> <div class="container"> ... </div> </body>
流式布局代码如下:
<div class="container-fluid"> <div class="row-fluid"> <div class="span2"> <!--Sidebar content--> </div> <div class="span10"> <!--Body content--> </div> </div> </div>
如果对Bootstrap提供的布局不够满意,可以参见Less Frame Work 提供的模板。
最后,再次强调,官方文档极其优秀,强烈推荐各位直接参考和学习之。http://twitter.github.com/bootstrap/index.html
参考文献与延伸阅读:
1.Bootstrap的来由和发展。http://www.alistapart.com/articles/building-twitter-bootstrap/
2.Less与Sass的介绍与对比.http://coding.smashingmagazine.com/2011/09/09/an-introduction-to-less-and-comparison-to-sass/
3.Html5模板 http://html5boilerplate.com/
4.Html5与Bootstrap混合项目(H5BP)https://gist.github.com/1422879
5.20个有用的Bootstrap资源 http://www.webresourcesdepot.com/20-beautiful-resources-that-complement-twitter-bootstrap/
6.Bootstrap按钮生成器 http://charliepark.org/bootstrap_buttons/
8. Bootstrap英文教程 http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/stepping-out-with-bootstrap-from-twitter/
本作品由VentLam创作,采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议进行许可。
<转载>Bootstrap 入门教程 http://www.cnblogs.com/ventlam/archive/2012/05/28/2520703.html 系列
标签:bsp 入门教程 common 学习 overflow ase body des 介绍
原文地址:http://www.cnblogs.com/FlyAway2013/p/6896000.html