gpt4 book ai didi

css - 有人可以帮我对齐图片旁边的文字吗?

转载 作者:行者123 更新时间:2023-11-28 08:42:16 25 4
gpt4 key购买 nike

我正在努力让文字位​​于图像旁边,但它并没有发生,请有人解释一下我在这里做错了什么?非常感谢!

    

.alignright {
float: right;
}

.source {
overflow: hidden;
width: auto;
height: 100%;
}

.source img {
width: 100%;
}


.margin25 {
margin:25px;
}
    <!--LEFT CONTAINER DIV-->
<div style="float:left;width:40%;margin-left:2%;">
<div class="source" style="width:20%;">
<img src="http://placehold.it/150x150">
</div>
<h1 class="alignright">Recommendations?</h1>
<br />
<h2 class="margin25">main text</h2>
</div>
<!--LEFT CONTAINER DIV-->

最佳答案

尝试在所有 3 个标签(img、h1、h2)中使用标签而不是带有 display:initial 的 div,并在 h1 和 h2 span 标签中将 float 属性设置为 right 或 left。

关于css - 有人可以帮我对齐图片旁边的文字吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27770354/

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