gpt4 book ai didi

css - 左侧文本、图像居中、右侧文本以及内联的所有内容

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

我有一个带有页眉、正文和页脚的容器 div。

现在我想将文本向左对齐,将图像和文本居中向右。一切都应该是内联的。

我尝试了 float left right & margin auto,但它不起作用Pull left center-block pull right (with bootstrap) 确实有效,但 pull right block 与其余部分不一致。

它应该是这样的:

left, center, right

有什么想法吗?

最佳答案

给你。

.first {
display: inline;
float: left;
}
.second {
display: inline;
float: left;
}
.third {
display: inline;
float: left;
}
<div>
<p class="first">1</p>
<img src="http://www.copsandrobbers.net/files/2012/09/lion.jpg" alt="lion image" class="second" />
<p class="third">3</p>
</div>

如果你想让文字在左右两侧,图片居中,你可以这样做:

div {
text-align: center;
}
.first {
display: inline;
float: left;
}
.second {
display: inline;
float: none;
}
.third {
display: inline;
float: right;
}
<div>
<p class="first">1</p>
<img src="http://www.copsandrobbers.net/files/2012/09/lion.jpg" alt="lion image" class="second" />
<p class="third">3</p>
</div>

关于css - 左侧文本、图像居中、右侧文本以及内联的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30305152/

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