CSS绘制星星评分实现分析

效果图:

 

    <div class="rating rating-3-half">
      <i class="star-1"></i>
      <i class="star-2"></i>
      <i class="star-3"></i>
      <i class="star-4"></i>
      <i class="star-5"></i>
    </div>

 

.rating {
  margin: 10px 0;
}
.rating-3-half .star-4 {
&nbsp; border-left-color: #f0991e;
}
.rating i {
&nbsp; display: inline-block;
&nbsp; width: 0;
&nbsp; height: 1.5em;
&nbsp; border-width: 0 0.75em;
&nbsp; border-style: solid;
&nbsp; border-color: #eee;
&nbsp; border-radius: .22em;
&nbsp; color: white;
&nbsp; background: #eee;
&nbsp; font-style: normal;
&nbsp; line-height: 1.6em;
&nbsp; text-indent: -0.5em;
&nbsp; text-shadow: 1px 0 1px #b3b3b3;
}

实现原理:设置包含星星的I元素高度后,然后设置其边框上下宽度为0,然后左右宽度为I元素高度的一半,需要实现半个星星时就使用border-left-color:属性。其他则设置一般的边框即可。IE6下不兼容

转载于:https://www.cnblogs.com/sakura-Master/p/4054169.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值