Bootstrap 排版

本文介绍Bootstrap框架中的排版技巧,包括不同级别的标题设置、显示类、辅助文本元素、引用块、列表定义等,并提供多种文本样式类以实现丰富的视觉效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、Bootstrap 排版

1.1 标题

Bootstrap 4 默认的 font-size 为 16px, line-height 为 1.5。
默认的 font-family 为 “Helvetica Neue”, Helvetica, Arial, sans-serif。
此外,所有的 <p> 元素 margin-top: 0 、 margin-bottom: 1rem (16px)。

<div class="container">
    <h1>h1 Bootstrap 标题 (2.5rem = 40px)</h1>
    <h2>h2 Bootstrap 标题 (2rem = 32px)</h2>
    <h3>h3 Bootstrap 标题 (1.75rem = 28px)</h3>
    <h4>h4 Bootstrap 标题 (1.5rem = 24px)</h4>
    <h5>h5 Bootstrap 标题 (1.25rem = 20px)</h5>
    <h6>h6 Bootstrap 标题 (1rem = 16px)</h6>

    <div class="h1">我是标题1 h1</div>
    <div class="h2" >我是标题2 h2</div>
    <div class="h3">我是标题3 h3</div>
    <div class="h4">我是标题4 h4</div>
    <div class="h5">我是标题5 h5</div>
    <div class="h6">我是标题6 h6</div>
</div>

1.2 Display 标题类

Bootstrap 还提供了四个 Display 类来控制标题的样式: .display-1, .display-2, .display-3, .display-4。

<h1 class="display-1">Display 1</h1>
<h1 class="display-2">Display 2</h1>
<h1 class="display-3">Display 3</h1>
<h1 class="display-4">Display 4</h1>

在这里插入图片描述

1.3 <small>

在 Bootstrap 4 中 HTML <small> 元素用于创建字号更小的颜色更浅的文本:

<div class="container">
    <h6>h6 标题 <small>副标题</small></h6>
    <h6>h6 标题 <span class="small">副标题</span></h6>
</div>

在这里插入图片描述

1.4 <mark>

Bootstrap 4 定义 <mark> 为黄色背景及有一定的内边距:

<div class="container">
    <h6>h6 标题 <mark>副标题</mark></h6>
    <h6>h6 标题 <span class="mark">副标题</span></h6>
</div>

在这里插入图片描述
1.5 <abbr>
Bootstrap 4 定义 HTML 元素的样式为显示在文本底部的一条虚线边框:

<div class="container">
    <h6>h6 标题 <abbr title="移动到我这里显示提示">副标题</abbr></h6>
    <h6>h6 标题 <span title="移动到我这里显示提示" class="abbr">副标题</span></h6>
</div>

在这里插入图片描述

1.6 <blockquote>

对于引用的内容可以在 <blockquote> 上添加 .blockquote 类 :

<div class="container">
  <h1>Blockquotes</h1>
  <p>The blockquote element is used to present content from another source:</p>
  <blockquote class="blockquote">
    <p>For 50 years, WWF has been protecting the future of nature. The world's leading conservation organization, WWF works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million globally.</p>
    <footer class="blockquote-footer">From WWF's website</footer>
  </blockquote>
</div>

在这里插入图片描述

1.7 <dl>

Bootstrap 4 定义 HTML <dl> 元素的样式如下

<div class="container">
  <h1>Description Lists</h1>    
  <p>The dl element indicates a description list:</p>
  <dl>
    <dt>Coffee</dt>
    <dd>- black hot drink</dd>
    <dt>Milk</dt>
    <dd>- white cold drink</dd>
  </dl>     
</div>

在这里插入图片描述

1.8 <code>

Bootstrap 4 定义 HTML 元素的样式如下:

<div class="container">
  <h1>代码片段</h1>
  <p>可以将一些代码元素放到 code 元素里面:</p>
  <p>以下 HTML 元素: <code>span</code>, <code>section</code>, 和 <code>div</code> 用于定义部分文档内容。</p>
</div>

在这里插入图片描述

1.9 <kbd>

Bootstrap 4 定义 HTML 元素的样式如下:

<div class="container">
  <h1>Keyboard Inputs</h1>
  <p>To indicate input that is typically entered via the keyboard, use the kbd element:</p>
  <p>Use <kbd>ctrl + p</kbd> to open the Print dialog box.</p>
</div>

在这里插入图片描述

1.10 <pre>

<div class="container">
<h1>Multiple Code Lines</h1>
<p>For multiple lines of code, use the pre element:</p>
<pre>
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both      spaces and
line breaks.
</pre>
</div>

在这里插入图片描述

1.11 更多排版类

描述
.font-weight-bold加粗文本
.font-weight-normal普通文本
.font-weight-light更细的文本
.font-italic斜体文本
.lead让段落更突出
.small指定更小文本 (为父元素的 85% )
.text-left左对齐
.text-center居中
.text-right右对齐
.text-justify设定文本对齐,段落中超出屏幕部分文字自动换行
.text-nowrap段落中超出屏幕部分不换行
.text-lowercase设定文本小写
.text-uppercase设定文本大写
.text-capitalize设定单词首字母大写
.initialism显示在 元素中的文本以小号字体展示,且可以将小写字母转换为大写字母
.list-unstyled移除默认的列表样式,列表项中左对齐 (
    1. 中)。 这个类仅适用于直接子列表项 (如果需要移除嵌套的列表项,你需要在嵌套的列表中使用该样式)
.list-inline将所有列表项放置同一行
.pre-scrollable使
 元素可滚动,代码块区域最大高度为340px,一旦超出这个高度,就会在Y轴出现滚动条
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

书香水墨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值