文字前的图标,并且图标尺寸大于文字尺寸(高度)的情况下CSS:
<div class="time green"> <i></i>限量抢,23点开放预热 </div>
CSS:
.posts .time{height: 37px; line-height: 37px;text-align: center;font-size: 14px;border-bottom: 1px dashed #ededed;}
.posts .green{color: #39b98d;}
.posts .green i{display:inline-block;/*必须*/
width: 18px; height: 18px;
background: url(../images/greentime.png) no-repeat;
position: relative;top: 3px;/*相对位置*/
margin-right: 3px;
}如果图标尺寸小于文字,甚至与文字高度一样的时候,就很容易,一旦图标尺寸明显大于文字,这时候就需要用到position: relative;相对定位去改变位置了。
版权说明:Copyright © 广州松河信息科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州松河信息科技有限公司 版权所有