gpt4 book ai didi

css - 如何使用 css 将 float 图像旁边的文本居中?

转载 作者:太空宇宙 更新时间:2023-11-04 12:21:40 25 4
gpt4 key购买 nike

<html>
<head>
<style type="text/css">
img{
float: left;
}
</style>
</head>
<body>
<img id="img" src="imgsource.jpg">
<h2> Text that should be next to the image. </h2>
<p> Text that should be below the image and heading. </p>
</body>
</html>

我遇到的问题是图片旁边的文字没有居中,当我希望下一段文字位于图片和标题下方时,它也会出现在图片旁边。

最佳答案

http://jsfiddle.net/dxbbog2k/

img {
vertical-align: middle;
width: 300px
}

h2{
display: inline;
}

p{
clear:both;
display: block;
}
<img id="img" src="http://dreamatico.com/data_images/kitten/kitten-3.jpg">
<h2> Text that should be next to the image. </h2>

<p>Text that should be below the image and heading.</p>

关于css - 如何使用 css 将 float 图像旁边的文本居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28326176/

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