温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

bootstrap不同级别标题

发布时间:2020-08-10 15:29:37 来源:网络 阅读:352 作者:9秒学院 栏目:开发技术

bootstrap不同级别标题

Bootstrap和普通的HTML页面一样,定义标题都是使用标签<h2>到<h7>,只不过Bootstrap覆盖了其默认的样式,使用其在所有浏览器下显示的效果一样,具体定义的规则可以如下表所示:

bootstrap不同级别标题

通过比较可以发现,Bootstrap标题样式进行了以下显著的优化重置:

1、重新设置了margin-topmargin-bottom的值,  h2~h4重置后的值都是20pxh5~h7重置后的值都是10px。
2、所有标题的行高都是1.1(也就是font-size的1.1倍),而且文本颜色和字体都继承父元素的颜色和字体。
3、固定不同级别标题字体大小,h2=36px,h3=30px,h4=24px,h5=18px,h6=14pxh7=12px。

标题的具体运用非常简单,和我们平时运用是一样的,使用<h2>~<h7>标签,分别表示标题一至标题六,h 后面的数字越大,表示级别越小,文本也越小。来看一个简单的效果:右侧代码编辑器中的10-16行的代码。

在Bootstrap中为了让非标题元素和标题使用相同的样式,还特意定义了.h2~.h7六个类名。

对比两个示例的效果图,可以说他们的效果是一模一样的。

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>标题(一)</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
</head>

<body>
<!--Bootstrap中的标题-->
<h2>Bootstrap标题一</h2>
<h3>Bootstrap标题二</h3>
<h4>Bootstrap标题三</h4>
<h5>Bootstrap标题四</h5>
<h6>Bootstrap标题五</h6>
<h7>Bootstrap标题六</h7>

<!--Bootstrap中让非标题元素和标题使用相同的样式-->
<div class="h2">Bootstrap标题一</div>
<div class="h3">Bootstrap标题二</div>
<div class="h4">Bootstrap标题三</div>
<div class="h5">Bootstrap标题四</div>
<div class="h6">Bootstrap标题五</div>
<div class="h7">Bootstrap标题六</div>

</body>
</html>

Bootstrap标题一

Bootstrap标题二

Bootstrap标题三

Bootstrap标题四
Bootstrap标题五
Bootstrap标题六

除此之外,我们在Web的制作中,常常会碰到在一个标题后面紧跟着一行小的副标题。在Bootstrap中他也考虑了这种排版效果,使用了<small>标签来制作副标题。这个副标题具有其自己的一些独特样式:

<!--Bootstrap中使用了<small>标签来制作副标题-->
<h2>Bootstrap标题一<small>我是副标题</small></h2>
<h3>Bootstrap标题二<small>我是副标题</small></h3>
<h4>Bootstrap标题三<small>我是副标题</small></h4>
<h5>Bootstrap标题四<small>我是副标题</small></h5>
<h6>Bootstrap标题五<small>我是副标题</small></h6>
<h7>Bootstrap标题六<small>我是副标题</small></h7>

1、行高都是1,而且font-weight设置了normal变成了常规效果(不加粗),同时颜色被设置为灰色(#999)。
2、由于<small>内的文本字体在h2~h4内,其大小都设置为当前字号的65%;而在h5~h7内的字号都设置为当前字号的75%;
详细代码请参阅bootstrap.css文件中第407行~第443行。

h2 small,
.h2 small,
h3 small,
.h3 small,
h4 small,
.h4 small,
h2 .small,
.h2 .small,
h3 .small,
.h3 .small,
h4 .small,
.h4 .small {
  font-size: 65%;
}
h5,
.h5,
h6,
.h6,
h7,
.h7 {
  margin-top: 10px;
  margin-bottom: 10px;
}
h5 small,
.h5 small,
h6 small,
.h6 small,
h7 small,
.h7 small,
h5 .small,
.h5 .small,
h6 .small,
.h6 .small,
h7 .small,
.h7 .small {
  font-size: 75%;
}


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI