gpt4 book ai didi

html - 文字在图片下方

转载 作者:太空宇宙 更新时间:2023-11-03 20:39:14 25 4
gpt4 key购买 nike

我正在为评论创建布局。但是,文字位于图像下方,我似乎无法摆脱它。

这是一个 JSFiddle演示问题。

.comments {
padding: 10px;
}
.comments .comment {
margin-bottom: 10px;
}
.comments .comment .profile-picture {
vertical-align: middle;
display: inline-block;
}
.comments .comment .text-block {
display: inline;
}
.timeago {
color: rgba(0, 0, 0, 0.5);
}
<div class="comments">

<div class="comment">

<div class="profile-picture">
<img src="http://fakeimg.pl/50x50/" />
</div>

<div class="text-block">
<a href="#">
Barack Obama
</a>

Change will not come if we wait for some other person or some other time. We are the ones we've been waiting for. We are the change that we seek.

<br />

<div class="timeago">20 hours ago</div>

</div>

<hr />

<div class="clear"></div>

</div>

<div class="clear"></div>
</div>

如何让文本位于图像下方?

最佳答案

你应该使用 display: inline-block。之后你应该给文本 block 一定的宽度,其中不大于 100% - 图像宽度(加上边距)。

.comments .comment .profile-picture {
vertical-align: middle;
display: inline-block;
}
.comments .comment .text-block {
display: inline-block;
vertical-align: middle;
width: calc(100% - 60px);
}

关于html - 文字在图片下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28482550/

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