我是靠谱客的博主 诚心帅哥,这篇文章主要介绍第二章之Bootstrap 页面排版样式,现在分享给大家,希望可以做个参考。

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。

复制代码
1
2
3
4
5
6
//创建包含段落突出的文本 <p>Bootstrap 框架</p> <p class="lead">Bootstrap 框架</p> <p>Bootstrap 框架</p> <p>Bootstrap 框架</p> <p>Bootstrap 框架</p>

2.标题

复制代码
1
2
3
4
5
6
7
//从 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)来实现相同的功能。

复制代码
1
2
//内联元素使用标题字体 <span class="h1">Bootstrap</span>

注:通过 Firebug 查看元素还看到,字体颜色、字体样式、行高均被固定了,从而保证了统一性,而原生的会根据系统内置的首选字体决定,颜色是最黑色。

在 h1 ~ h6 元素之间,还可以嵌入一个 small 元素作为副标题,

复制代码
1
2
3
4
5
6
7
//在标题元素内插入 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.内联文本元素

复制代码
1
2
3
4
5
6
7
8
9
10
11
//添加标记,<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>//倾斜

4.对齐

复制代码
1
2
3
4
5
//设置文本对齐 <p class="text-left">Bootstrap 框架</p>//居左 <p class="text-center">Bootstrap 框架</p>//居中 <p class="text-right">Bootstrap 框架</p>//居右 <p class="text-justify">Bootstrap 框架</p>//两端对齐,支持度不佳<p class="text-nowrap">Bootstrap 框架</p>//不换行

5.大小写

复制代码
1
2
3
4
//设置英文文本大小写 <p class="text-lowercase">Bootstrap 框架</p> //小写 <p class="text-uppercase">Bootstrap 框架</p> //大写 <p class="text-capitalize">Bootstrap 框架</p>//首字母大写

6.缩略语

复制代码
1
2
//缩略语 Bootstrap<abbr title="Bootstrap" class="initialism">框架</abbr>

7.地址文本

复制代码
1
2
3
4
5
6
7
//设置地址,去掉了倾斜,设置了行高,底部 20px <address>   <strong>Twitter, Inc.</strong><br>   795 Folsom Ave, Suite 600<br>   San Francisco, CA 94107<br>   <abbr title="Phone">P:</abbr> (123) 456-7890 </address>

8.引用文本

复制代码
1
2
3
4
5
6
7
8
//默认样式引用,增加了做边线,设定了字体大小和内外边距 <blockquote>   Bootstrap 框架 </blockquote> //反向 <blockquote class="blockquote-reverse ">   Bootstrap 框架 </blockquote>

9.列表排版

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//移出默认样式 <ul class="list-unstyled">   <li>Bootstrap 框架</li>   <li>Bootstrap 框架</li>   <li>Bootstrap 框架</li>   <li>Bootstrap 框架</li>   <li>Bootstrap 框架</li> </ul> //设置成内联 <ul class="list-inline">   <li>Bootstrap 框架</li>   <li>Bootstrap 框架</li>   <li>Bootstrap 框架</li>   <li>Bootstrap 框架</li>   <li>Bootstrap 框架</li> </ul> //水平排列描述列表 <dl class="dl-horizontal">   <dt>Bootstrap</dt>   <dd>Bootstrap 提供了一些常规设计好的页面排版的样式供开发者使用。</dd> </dl>

10.代码

复制代码
1
2
3
4
5
6
//内联代码 <code><section></code> //用户输入 press <kbd>ctrl + ,</kbd> //代码块 <pre><p>Please input...</p></pre>

Bootstrap 还列举了<var>表示标记变量,<samp>表示程序输出,只不过没有重新复写 CSS。

以上所述是小编给大家介绍的Bootstrap 页面排版样式的相关知识,希望对对大家有所帮助!

最后

以上就是诚心帅哥最近收集整理的关于第二章之Bootstrap 页面排版样式的全部内容,更多相关第二章之Bootstrap内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(124)

评论列表共有 0 条评论

立即
投稿
返回
顶部