Bootstrap,来自 Twitter,是目前最受欢迎的前端框架。Bootstrap 是基于 HTML、CSS、JAVASCRIPT 的,它简洁灵活,使得 Web 开发更加快捷。
学习要点:
1.页面排版
本节课我们主要学习一下 Bootstrap 全局 CSS 样式中的排版样式,包括了标题、页面主体、对齐、列表等常规内容。
一.页面排版
Bootstrap 提供了一些常规设计好的页面排版的样式供开发者使用。
1.页面主体
Bootstrap 将全局 font-size 设置为 14px,line-height 行高设置为 1.428(即20px);<p>段落元素被设置等于 1/2 行高(即 10px);颜色被设置为#333。
//创建包含段落突出的文本<p>Bootstrap 框架</p><p class="lead">Bootstrap 框架</p><p>Bootstrap 框架</p><p>Bootstrap 框架</p><p>Bootstrap 框架</p>
2.标题
//从 h1 到 h6<h1>Bootstrap 框架</h1>//36px<h2>Bootstrap 框架</h2>//30px<h3>Bootstrap 框架</h3>//24px<h4>Bootstrap 框架</h4>//18px<h5>Bootstrap 框架</h5>//14px<h6>Bootstrap 框架</h6>//12px
我们从 Firebug 查看元素了解到, Bootstrap 分别对 h1 ~ h6 进行了 CSS 样式的重构,并且还支持普通内联元素定义 class=(.h1 ~ h6)来实现相同的功能。
//内联元素使用标题字体<span class="h1">Bootstrap</span>
注:通过 Firebug 查看元素还看到,字体颜色、字体样式、行高均被固定了,从而保证了统一性,而原生的会根据系统内置的首选字体决定,颜色是最黑色。
在 h1 ~ h6 元素之间,还可以嵌入一个 small 元素作为副标题,
//在标题元素内插入 small 元素<h1>Bootstrap 框架 <small>Bootstrap 小标题</small></h1><h2>Bootstrap 框架 <small>Bootstrap 小标题</small></h2><h3>Bootstrap 框架 <small>Bootstrap 小标题</small></h3><h4>Bootstrap 框架 <small>Bootstrap 小标题</small></h4><h5>Bootstrap 框架 <small>Bootstrap 小标题</small></h5><h6>Bootstrap 框架 <small>Bootstrap 小标题</small></h6>
通过 Firebug 查看,我们发现 h1 ~ h3 下 small 元素的大小只占父元素的 65%,那么通过计算(查看 Firebug 计算后的样式), h1 ~ h3 下的 small 为 23.4px、 19.5px、 15.6px;h4 ~ h6 下 small 元素的大小只占父元素的 75% ,分别为:13.5px、10.5px、9px。在 h1 ~ h6 下的 small 样式也进行了改变,颜色变成淡灰色:#777,行高为 1,粗度为 400。
3.内联文本元素
//添加标记,<mark>元素或.mark 类<p>Bootstrap<mark>框架</mark></p> //各种加线条的文本<del>Bootstrap 框架</del>//删除的文本<s>Bootstrap 框架</s>//无用的文本<ins>Bootstrap 框架</ins>//插入的文本<u>Bootstrap 框架</u>//效果同上,下划线文本 //各种强调的文本<small>Bootstrap 框架</small>//标准字号的 85%<strong>Bootstrap 框架</strong>//加粗 700<em>Bootstrap 框架</em>//倾斜
新闻热点
疑难解答
图片精选