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

这是一个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>





我如何才能使文本不位于图像下方?

最佳答案

您可以将两个div的显示都更改为table-cell

.comments .comment .profile-picture, .comments .comment .text-block{
    display:table-cell
}


jsFiddle example

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

10-12 14:09