在电商项目中,经常会搞活动,标上价格后,后面再跟个活动名称,例如:
代码如下:
<html>
<head>
<style type="text/css">
.cls{
width: 60px;
height: 40px;
background-color: red;
text-align: center;
line-height: 40px;
display: inline-block;
vertical-align: text-bottom
}
</style>
</head>
<body>
<div >
<span style="font-size: 20px">¥</span>
<span style="font-size: 60px;">2999</span>
<span style="font-size: 20px;">.90</span>
<div class="cls">优惠价</div>
</div>
<script>
</script>
</body>
</html>
我们设置了vertical-align为text-bottom,从图中我们看到并没有底边对齐,有没有办法让它们一点不差的底边对齐呢?设置vertical-align为12px就可以了,效果如下:
这下我们看到确实整齐划一了,达到了像素级别的底边对齐。