html - 将图标添加到 jumbotron 中的标题项
问题描述
我有以下jumbotron:
通过创建:
<div class="col-sm-2">
<div class="jumbotron jumbotron-fluid top-space">
<div class="container">
<h1 class="display-6">Initiatives</h1>
<p class="lead">The other good stuff.</p>
<ul>
<li>
<a href="">Start an Initiative »</a></li>
<li>
<a href="">More Information »</a></li>
</ul>
</div>
</div>
<div class="jumbotron jumbotron-fluid top-space">
<div class="container">
<h1 class="display-6">News</h1>
<p class="lead">Our Search Tool. <br> Love at first, second, third, fourth, fifth, and sixth sight.</p>
<a href="">Try it out »</a>
</div>
</div>
</div>
我想要一个红色方块上的图标。如何添加并将其与我的 h1、display-6 对齐?
解决方案
.col-sm-2 > div:first-child .display-6::after{
content: "" ;
width: 40px;
height: 40px;
background-color: red;
display: block;
margin-left: 20px;
}
.col-sm-2 > div:first-child .display-6{
display: inline-flex;
}
<div class="col-sm-2">
<div class="jumbotron jumbotron-fluid top-space">
<div class="container">
<h1 class="display-6">Initiatives</h1>
<p class="lead">The other good stuff.</p>
<ul>
<li>
<a href="">Start an Initiative »</a></li>
<li>
<a href="">More Information »</a></li>
</ul>
</div>
</div>
<div class="jumbotron jumbotron-fluid top-space">
<div class="container">
<h1 class="display-6">News</h1>
<p class="lead">Our Search Tool. <br> Love at first, second, third, fourth, fifth, and sixth sight.</p>
<a href="">Try it out »</a>
</div>
</div>
</div>
推荐阅读
- matlab - 在 MATLAB 命令行终端中查看工作区
- javascript - 如何在Highcharts的样条图中显示两个日期范围之间的数据?
- sql - 如果行在其他列中具有相同的数据,则 SQL 查询 CONCAT/列出唯一列数据?
- javascript - 如何在反应中更新深层嵌套状态?
- netbeans - 在 NetBeans IDE 中使用 JDK11 启动 GlassFish 服务器
- python - 如何仅在 while 循环中运行 1 次操作
- javascript - 触发反应选择 onchange
- php - 在 php api 上验证图像文件时出错
- python - 安装 web3 时如何解决此错误
- java - 每次加载页面时,如何使用 Hibernate 将自动增量计数保存在数据库中?