zoukankan      html  css  js  c++  java
  • 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下不兼容

  • 相关阅读:
    Type Safety and Type Inference
    LEARN SWIFT
    swift 类型备份
    Swift
    associatedtype关联类型
    深入理解 Swift 派发机制
    Swift中self和Self
    Postfix Self Expression
    CGContext与上下文
    eeee
  • 原文地址:https://www.cnblogs.com/sakura-Master/p/4054169.html
Copyright © 2011-2022 走看看