html - 在引导程序中的 div 元素内居中图像
问题描述
我使用引导程序,我想知道为什么当我将最大宽度应用于图像时,它不考虑文本中心并且是分散的。只需删除最大宽度以使其再次居中。
<div class="img-rsa g-4 align-self-center text-center">
<img src="img/aluno-rsa.jpg" alt="" class="img-fluid" style="border-radius:100%">
</div>
.img-rsa {
width: 100%;
max-width: 350px;
display: block;
}
解决方案
您需要将宽度设置应用于图像。
.img-fluid {
width: 100%;
max-width: 350px;
height: auto: // You need to add this
display: block;
}
然后由于图像现在是块状的,您可以使用边距自动将其居中。或者您可以保持图像内联并使用文本对齐将其居中。
推荐阅读
- vb.net - 是否可以从 Dropbox 链接获取 .EXE 文件版本?
- c# - 将 Spritefont 分配到类中
- mysql - 选择仅在上个月每三个发生的数据,以及仅在上个月的前三个和最后三个发生的数据
- php - 我的错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册
- google-sheets - 将亚马逊列表中的文本提取到 Google 表格中的最佳方法是什么?
- python - 如何在 django 上更新时检查唯一性
- javascript - 如何使用 ACE 编辑器运行 Python
- qt - 来自 QKeyEvent 的文本输入不适用于 QTextDocument 中的俄语字母
- c# - <%@ 注册程序集="Microsoft.ReportViewer.WebForms, >
- godot - 如何修复 Godot 中的“基础运动体上的无效设置索引位置”错误?