首页 > 解决方案 >

与文本相同的行,和

相同高度

问题描述

我正在努力实现以下目标:

--------------------------------------------------
|         | Text: Hello, World! I am a paragraph |
|  Image  | with the same line and height of the |
|         | image                                |
--------------------------------------------------

我试图给标签样式“inline-block”,但什么也没做:

<div>
    <img src="image.png" alt="image" style="inline-block">
    <p>Hello, World! I am a paragraph with the same line and height of the image</p>
</div>

编辑: display:flex;完成了这项工作,但我想补充一点,我也用过align-self:center;<img>这样图像就不会拉伸

标签: css

解决方案


<div style="display: flex">
    <img src="image.png" alt="image">
    <p>Hello, World! I am a paragraph with the same line and height of the image</p>
</div>

尝试这个。


推荐阅读