HTML中让img和span中的文字保持同一水平线

HTML中让img和span中的文字保持同一水平线

在这里插入图片描述

<div style="line-height: 40px;>
	<img src="${pageContext.request.contextPath}/image/logo.jpg"  style="width:80px;height:60px;">
	<span style="font-size: 20px;font-weight:bold;">后台管理</span>
</div>

img使用vertical-align:middle:
或者
img使用display:inline-block;

<div style="line-height: 40px;>
	<img src="${pageContext.request.contextPath}/image/logo.jpg"
	        style="width:80px;height:60px;vertical-align: bottom;">
	<span style="font-size: 20px;font-weight:bold;">后台管理</span>
</div>

在这里插入图片描述

img和span中的文字底部对齐

vertical-align: bottom;

在这里插入图片描述
img和span中的文字顶部对齐

vertical-align: -webkit-baseline-middle;

在这里插入图片描述

还有多个属性
在这里插入图片描述
可以自己尝试一下其中不同

猜你喜欢

转载自blog.csdn.net/qq_42583263/article/details/116237760
今日推荐