问题在于,一个div向下移动而另一个又向上移动,为什么?
我做了两个double div,它们都是内联块且向右浮动,每个块内都相同。
我尝试了许多更改,没有任何解决方案。



.lawyer-online {
	display: inline-block;
	width: 200px;
	height: 100px;
	margin: 10px;
}
.lawyer-avatar {
	display: inline-block;
	height: 100px;
	width: 100px;
	float:right;
}
.lawyer-avatar-relative {
	position: relative;
}
.lawyer-name-box{
	position: absolute;
	bottom: 0em;
	right: 0em;
	width: 100%;
	height: 2em;
    background: rgba(25, 126, 215, 0.9);
	color: #fff;
}
.lawyer-name-box span{
	padding: 10px 10px 10px 0;
}
.lawyer_description {
	background: rgba(25, 126, 215, 0.5);
	height: 100px;
	width: 100px;
	display: inline-block;
	clear: right;
}

<div id="lawyer-1" class="lawyer-online">
	<div class="lawyer-avatar">
		<div class="lawyer-avatar-relative">
			<img src="http://wdd.co.il/wp-content/uploads/2015/08/angry-judge-100x100.jpg">
			<div class="lawyer-name-box">
				<span>name name</span>
			</div>
		</div>
	</div>
	<div class="lawyer_description">short text</div>
</div>
<div id="lawyer-2" class="lawyer-online">
	<div class="lawyer-avatar">
		<div class="lawyer-avatar-relative">
			<img src="http://wdd.co.il/wp-content/uploads/2015/08/angry-judge-100x100.jpg">
			<div class="lawyer-name-box">
				<span>name name</span>
			</div>
		</div>
	</div>
	<div class="lawyer_description">long text long text long text</div>
</div>





html - CSS两个double div,一个固定的1个水平移位-LMLPHP

问题在于,一个div向下移动而另一个又向上移动,为什么?
我做了两个double div,它们都是内联块且向右浮动,每个块内都相同。
我尝试了许多更改,没有任何解决方案。

最佳答案

发生这种现象的原因是inline-block默认情况下会接收vertical-align: baseline,而该vertical-align: top并不总是以所需的方式对齐元素。

您可以通过在声明块中为.lawyer-online显式指定来纠正此问题。 (或中间/底部,它们也可以作为值使用。)



.lawyer-online {
	display: inline-block;
	width: 200px;
	height: 100px;
	margin: 10px;
	vertical-align: top;
}
.lawyer-avatar {
	display: inline-block;
	height: 100px;
	width: 100px;
	float:right;
}
.lawyer-avatar-relative {
	position: relative;
}
.lawyer-name-box{
	position: absolute;
	bottom: 0em;
	right: 0em;
	width: 100%;
	height: 2em;
    background: rgba(25, 126, 215, 0.9);
	color: #fff;
}
.lawyer-name-box span{
	padding: 10px 10px 10px 0;
}
.lawyer_description {
	background: rgba(25, 126, 215, 0.5);
	height: 100px;
	width: 100px;
	display: inline-block;
	clear: right;
}

<div id="lawyer-1" class="lawyer-online">
	<div class="lawyer-avatar">
		<div class="lawyer-avatar-relative">
			<img src="http://wdd.co.il/wp-content/uploads/2015/08/angry-judge-100x100.jpg">
			<div class="lawyer-name-box">
				<span>name name</span>
			</div>
		</div>
	</div>
	<div class="lawyer_description">short text</div>
</div>
<div id="lawyer-2" class="lawyer-online">
	<div class="lawyer-avatar">
		<div class="lawyer-avatar-relative">
			<img src="http://wdd.co.il/wp-content/uploads/2015/08/angry-judge-100x100.jpg">
			<div class="lawyer-name-box">
				<span>name name</span>
			</div>
		</div>
	</div>
	<div class="lawyer_description">long text long text long text</div>
</div>

10-04 17:31