当前位置: 首页 > news >正文

【Bootstrap V4系列】学习入门教程之 组件-卡片(Card)

Bootstrap V4系列 学习入门教程之 组件-卡片(Card)

  • 卡片(Card)
    • 一、Example
    • 二、Content types 内容类型
      • 2.1 Body 主体
      • 2.2 Titles, text, and links 标题、文本和链接
      • 2.3 Images 图片
      • 2.4 List groups 列表组
      • 2.5 Kitchen sink 洗涤槽
      • 2.6 Header and footer 页眉和页脚

卡片(Card)

Bootstrap的卡片提供了一个灵活且可扩展的内容容器,其中包含多种变体和选项。

一、Example

卡片尽可能少地使用标记和样式构建,但仍然能够提供大量的控制和定制。它们采用flexbox构建,易于对齐,并与其他Bootstrap组件很好地混合。默认情况下,它们没有边距,因此根据需要使用间距实用程序。

下面是一个具有混合内容和固定宽度的基本卡的示例。卡片开始时没有固定的宽度,因此它们自然会填充其父元素的整个宽度。这很容易通过我们的各种尺寸选项进行定制。

<!--Example-->
<div class="card" style="width: 18rem;"><img src="../images/a1.jpg" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p><a href="#" class="btn btn-primary">Go somewhere</a></div>
</div>

页面展示效果:

在这里插入图片描述

二、Content types 内容类型

卡片支持各种各样的内容,包括图像、文本、列表组、链接等。下面是支持的示例。

2.1 Body 主体

卡片的构建块是.card-body。每当你需要卡片中的填充部分时,都可以使用它。

<div class="card"><div class="card-body">This is some text within a card body.</div>
</div>

页面展示效果:

在这里插入图片描述

2.2 Titles, text, and links 标题、文本和链接

卡片标题是通过在<h*>标签中添加.card-title来使用的。同样,通过在<a>标签中添加.card-link,可以添加链接并将其放置在彼此旁边。

字幕是通过在<h*>标签中添加.card-subtitle字幕来使用的。如果.card-title.card-subtitle副标题项放置在.card-body正文项中,则卡标题和副标题会很好地对齐。

<div class="card" style="width: 18rem;"><div class="card-body"><h5 class="card-title">Card title</h5><h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6><p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p><a href="#" class="card-link">Card link</a><a href="#" class="card-link">Another link</a></div>
</div>

页面展示效果:

在这里插入图片描述

2.3 Images 图片

.card-img-top 将图像放置在卡的顶部。使用.card-text文本,可以将文本添加到卡中。.card-text中的文本也可以使用标准HTML标签进行样式设置。

<div class="card" style="width: 18rem;"><img src="..." class="card-img-top" alt="..."><div class="card-body"><p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p></div>
</div>

页面展示效果:

在这里插入图片描述

2.4 List groups 列表组

使用刷新列表组在卡片中创建内容列表。

<div class="card" style="width: 18rem;"><div class="card-header">Featured</div><ul class="list-group list-group-flush"><li class="list-group-item">An item</li><li class="list-group-item">A second item</li><li class="list-group-item">A third item</li></ul>
</div>

页面展示效果:

在这里插入图片描述

<div class="card" style="width: 18rem;"><ul class="list-group list-group-flush"><li class="list-group-item">An item</li><li class="list-group-item">A second item</li><li class="list-group-item">A third item</li></ul><div class="card-footer">Card footer</div>
</div>

页面展示效果:

在这里插入图片描述

2.5 Kitchen sink 洗涤槽

混合和匹配多种内容类型以创建所需的卡片,或将所有内容都放在其中。下面显示的是图像样式、块、文本样式和列表组,所有这些都包装在固定宽度的卡片中。

<div class="card" style="width: 18rem;"><img src="..." class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p></div><ul class="list-group list-group-flush"><li class="list-group-item">An item</li><li class="list-group-item">A second item</li><li class="list-group-item">A third item</li></ul><div class="card-body"><a href="#" class="card-link">Card link</a><a href="#" class="card-link">Another link</a></div>
</div>

页面展示效果:

在这里插入图片描述

2.6 Header and footer 页眉和页脚

在卡片中添加可选的页眉和/或页脚。

<div class="card"><div class="card-header">Featured</div><div class="card-body"><h5 class="card-title">Special title treatment</h5><p class="card-text">With supporting text below as a natural lead-in to additional content.</p><a href="#" class="btn btn-primary">Go somewhere</a></div>
</div>

页面展示效果:
在这里插入图片描述

可以通过在<h*>元素中添加.card-header来设置卡头样式。

<div class="card"><h5 class="card-header">Featured</h5><div class="card-body"><h5 class="card-title">Special title treatment</h5><p class="card-text">With supporting text below as a natural lead-in to additional content.</p><a href="#" class="btn btn-primary">Go somewhere</a></div>
</div>

页面展示效果:

在这里插入图片描述

设置页眉,卡片内容是块引用

<div class="card"><div class="card-header">Quote</div><div class="card-body"><blockquote class="blockquote mb-0"><p>A well-known quote, contained in a blockquote element.</p><footer class="blockquote-footer">Someone famous in <cite title="Source Title">Source Title</cite></footer></blockquote></div>
</div>

页面展示效果:

在这里插入图片描述

设置页眉和页脚,卡片内容文本居中

<div class="card text-center"><div class="card-header">Featured</div><div class="card-body"><h5 class="card-title">Special title treatment</h5><p class="card-text">With supporting text below as a natural lead-in to additional content.</p><a href="#" class="btn btn-primary">Go somewhere</a></div><div class="card-footer text-muted">2 days ago</div>
</div>

页面展示效果:

在这里插入图片描述

相关文章:

  • 因为gromacs必须安装cuda(系统自带的NVIDIA驱动不行),这里介绍下如何安装cuda
  • SpringMVC——第6章:RESTFul编程风格
  • 51c大模型~合集124
  • 【从零开始学习微服务 | 第一篇】单体项目到微服务拆分实践
  • 深入理解 Bash 中的 $‘...‘ 字符串语法糖
  • DXFViewer进行中 : ->封装OpenGL -> 解析DXF直线
  • Compose 中使用 WebView
  • Unity:输入系统(Input System)与持续检测键盘按键(Input.GetKey)
  • win10开了移动热点,手机无法连接,解决办法(chatgpt版)
  • socket,http
  • 基于python的哈希查表搜索特定文件
  • 查看Ubuntu版本
  • (41)VTK C++开发示例 ---qt使用vtk最小示例
  • 科创大赛——知识点复习【c++】——第一篇
  • Flink流水线任务在线演示
  • 《类和对象(上)》
  • Python 整理3种查看神经网络结构的方法
  • 虚幻引擎作者采访
  • 什么是原码、反码与补码?
  • 2025流感疫苗指南+卫健委诊疗方案|高危人群防护+并发症处理 慢性肾脏病饮食指南2025卫健委版|低盐低磷食谱+中医调理+PDF 网盘下载 pdf下载
  • “子宫肌瘤男性病例”论文后:“宫颈癌、高危产妇”论文也现男性病例,作者称“打错了”
  • 美国内政部长:今年夏天美国可能发生西班牙式大停电,全怪拜登
  • 涉“子宫肌瘤”论文现55例男性对照观察患者?山大齐鲁医院:正在调查
  • 抚州一原副县长拉拢公职人员组建“吃喝圈”,长期接受打牌掼蛋等“保姆式”服务
  • 浙江一文旅局长五一亲自带团,去年专门考取了导游证
  • 全国铁路旅客发送量连续3天同比增幅超10%,今日预计发送1800万人次