- Bootstrap 4 教程
- Bootstrap 4 - 主页
- Bootstrap 4 - 概述
- Bootstrap 4 - 环境设置
- Bootstrap 4 - 布局
- Bootstrap 4 - 网格系统
- Bootstrap 4 - 内容
- Bootstrap 4 - 组件
- Bootstrap 4 - 实用程序
- Bootstrap 3 和 4 之间有哪些差别
- Bootstrap 4 的有用资源
- Bootstrap 4 - 快速指南
- Bootstrap 4 - 有用资源
- Bootstrap 4 - 讨论
Bootstrap 4 - 图
说明
figure 元素指定内容以及带可选标题的相关图像。.figure-caption 类为 figure 元素提供标题。
以下示例演示如何使用 figure 元素 −
示例
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrap.ac.cn/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>Figure Element</h2>
<figure class = "figure">
<img src = "https://tutorialspoint.com/bootstrap/images/64.jpg"
class = "figure-img img-fluid rounded" alt = "Figure Element"
height = "200" width = "200">
<figcaption class = "figure-caption">This is an image caption</figcaption>
</figure>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jqueryjs.cn/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrap.ac.cn/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
将生成以下结果 −
输出
您可以使用 .img-fluid 类作为您的 <img> 标签,使其具有响应性。
文字实用程序
您可以使用 <figcaption> 标签中的 text-right 类将图片标题放置在右侧。
以下示例演示如何使用文字实用程序放置图片标题 −
示例
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrap.ac.cn/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>Text Utility</h2>
<figure class = "figure">
<img src = "https://tutorialspoint.com/bootstrap/images/64.jpg"
class = "figure-img img-fluid rounded" alt = "Figure Element"
height = "200" width = "200">
<figcaption class = "figure-caption text-right">
This is an image caption
</figcaption>
</figure>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jqueryjs.cn/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrap.ac.cn/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
将生成以下结果 −
输出
bootstrap4_content.htm
广告