html - 如何对齐图片下方的简短文字?
问题描述
我正在尝试将我的demo
文本对齐到我的图像下方。我目前正在使用引导程序,但是如何在图像下方和::after
div 之间对齐图标>
布局
<section>
<h2 class="main-title">
<font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Test process</font></font>
</h2>
<div class="container demo">
<div class="row" style="text-align: center;">
<div class="steps">
<img src="https://code.google.com/images/developers.png" style="height: 80px;" />
</div>
<div class="col-md-6 col-xs-6">
<h2 class="steps__title">How It Works</h2>
<p>demo</p>
</div>
</div>
<div class="row" style="text-align: center;">
<div class="steps">
<img src="https://code.google.com/images/developers.png" style="height: 80px;" />
</div>
<div class="col-md-6 col-xs-6">
<h2 class="steps__title">How It Works</h2>
<p>demo</p>
</div>
</div>
<div class="row" style="text-align: center;">
<div class="steps">
<img src="https://code.google.com/images/developers.png" style="height: 80px;" />
</div>
<div class="col-md-6 col-xs-6">
<h2 class="steps__title">How It Works</h2>
<p>demo</p>
</div>
</div>
</div>
</section>
解决方案
首先,您使用的引导程序非常错误。请研究如何在 Bootstrap 上使用容器、行、弹性和列。在这里检查。其次,始终在 col 中使用单独的 div。
这是我的片段检查这个,请你预览整个页面。
.icon img {
margin-top: 10px;
}
.details h2 {
font-weight: 400;
font-size: 25px;
color:#515f7f;
}
.details p {
margin-top: -5px;
}
<!DOCTYPE html>
<html>
<head>
<title>arg0-container</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
</head>
<body>
<section class="mt-5">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="icon d-flex">
<img src="https://code.google.com/images/developers.png" height="80px" />
<div class="details ml-4 mt-2 text-center d-block">
<h2>How It <br> Works</h2>
<p>Demo</p>
</div>
</div>
<p class="ml-2 mt-3">Lorem ipsum dolor sit amet!</p>
</div>
<div class="col-md-4">
<div class="icon d-flex">
<img src="https://code.google.com/images/developers.png" height="80px" />
<div class="details ml-4 mt-2 text-center d-block">
<h2>How It <br> Works</h2>
<p>Demo</p>
</div>
</div>
<p class="ml-2 mt-3">Lorem ipsum dolor sit amet!</p>
</div>
<div class="col-md-4">
<div class="icon d-flex">
<img src="https://code.google.com/images/developers.png" height="80px" />
<div class="details ml-4 mt-2 text-center d-block">
<h2>How It <br> Works</h2>
<p>Demo</p>
</div>
</div>
<p class="ml-2 mt-3">Lorem ipsum dolor sit amet!</p>
</div>
</div>
</div>
</section>
</body>
</html>
推荐阅读
- sql-server - 如何从本地 SQL Server 2016 迁移到 Azure SQL Hyperscale
- mips - 了解字符串如何存储在 MIPS 中以及如何计算字符串中的字符数
- reactjs - 在 reactjs 中集成条带支付网关时出现 cors 问题
- pentaho - Pentaho 不会注册我的插件:注册 jar 插件时出现意外错误
- ssl - Wso2 Ei 6.3 自签名认证错误
- python - 如何从熊猫系列中的字符串中去除“$”符号?
- python-3.7 - ValueError:无法将字符串转换为浮点数:'ill afb'
- udp - NS3 中的 UDP 吞吐量计算
- pdf - 如何导出具有反转背景和文本颜色的 PDF
- erlang - Ejabberd 的 CPU 使用率很高,并将非活动用户显示为已连接