gpt4 book ai didi

html - 对齐图像的顶部和相邻 div 的顶部

转载 作者:行者123 更新时间:2023-11-28 14:36:18 24 4
gpt4 key购买 nike

我有一个图像与一个 div 作为邻居,我似乎无法让元素的顶部相互对齐。 div 中的文本最终与图像底部对齐。

所以我基本上有以下 HTML:

<img src="" /><div class="block">This lines up with the bottom of the image.</div>

我必须应用哪种 CSS 才能使元素的顶部彼此对齐?

我用 google 搜索了“align image div”,但找不到解决问题的方法。

提前致谢。

最佳答案

float 是否符合您的要求? http://jsfiddle.net/Ma2c5/

img { float: left }
div.block { float: left }

您可能想在这些元素之后清除 float ,请阅读 http://www.quirksmode.org/css/clearing.html 上的主题

关于html - 对齐图像的顶部和相邻 div 的顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6687310/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com