css - 和
与文本相同的行,和
相同高度
问题描述
我正在努力实现以下目标:
--------------------------------------------------
| | 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>
这样图像就不会拉伸
解决方案
<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>
尝试这个。
推荐阅读
- android - 用于 Firebase 数据更新的 setValue() 导致更新对象中的其他字段在 childEventListener 中的 onChildAdded 中返回 null
- python - 在 Linux 中编写的 django 项目如何运行,我有 Windows 吗?
- javascript - 在 AJAX 返回的元素仍然可见时暂停 HTML5 音频
- google-cloud-platform - WinScp SFTP - 没有支持的身份验证方法可用谷歌云
- php - 条卡处理
- c - 将一个引脚配置为输入而另一个引脚配置为输出时 AVR 端口上的奇怪行为
- javascript - 使用 JS 在已填充的选择标签中选择一个选项
- cookies - 谷歌“同意”cookie - 它是什么?
- javascript - 从解析的 html 中获取文本值
- c++ - Firebase:架构 x86_64 的未定义符号(配置多个项目)