html - 使用“中心”将图像水平居中
问题描述
我无法将图像水平居中。这是我的代码:
<img src="https://dummyimage.com/300x200/000/fff" alt="johnson johnson" style="width:300px; height:225px;" class="center">
我究竟做错了什么?谢谢你的时间。
解决方案
只需在图像前添加 p 标签并为其添加样式即可。
<p style="text-align: center;">
<img src="https://dummyimage.com/300x200/000/fff" alt="johnson johnson" style="width:300px;height:225px;>
</p>
推荐阅读
- r - 在R中按等级和条件提取行
- google-sheets - 在 Google 表格中,如何检查单元格 A(日期)是否在单元格 B 和 C 的日期范围内
- c# - 来自@drawable的编辑文本不显示背景图像
- php - 如何在同一个容器中运行 cron 和 Web 应用程序?
- c# - Automapper 展开到列表
- node.js - 猫鼬在提取信息的同时更新数百万条记录
- javascript - 当为 localstorage 添加 location.reload 以外的数据时,如何将其打印出来?
- html - 将分享问题链接到 Facebook 和 Linkedin?
- sqlite - SQLiteOpenHelper AndroidStudio 的 writableData 问题 - Kotlin
- javascript - 将页面重定向到 fb