html - 将文本与图像对齐

标签 html css

我需要将文本与图像对齐。

我试过,对齐顶部,对齐图像的中心。以及分别为图像和文本向左和向右浮动。仍然没有用。

<p>
  <img class="calendar" src="img/calendar-icon.png" /> 
  System will go under maintenance from 15 Jan 2019 06.00 to 20 Jan 2019 10.00. Sorry for any inconveniences caused.
</p>

截图并发布结果如上代码和我真正想要的。

enter image description here

最佳答案

使用 Flex

.list{display:flex;}
.img-block{width:80px; margin-right:20px}
.img-block img{max-width:100%}
p{margin:0;}
<div class="list">
<div class="img-block">
  <img src="https://image.flaticon.com/icons/png/512/26/26012.png" />
</div>
<p>System will go under maintenance from 15 Jan 2019 06.00 to 20 Jan 2019 10.00. Sorry for any inconveniences caused.</p>
<div>

关于html - 将文本与图像对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56538496/

相关文章:

php - 使用单独的链接 php 文件获取当前 session 信息

css - 如何在 jQuery Mobile 中定位按钮

javascript - 如何让INPUT元素填满整个表格TD单元格

javascript - 将类添加到单个元素而不是全部在悬停时使用 JQuery

javascript - 如何通过 jquery 分别管理多个 setInterval 函数

html - 液体布局中垂直边距与水平边距成比例

css - JQuery Mobile、Bootstrap 和 CSS3 Media Queries,选择什么组合

css - 滚动的 flex 容器不适合居中的元素

javascript - 单击更改按钮中的图像

javascript - 如何使用 Javascript 选择 html select 元素中的所有值