半星用CSS

zak*_*zak 3 html css rating

如何在IE和Chrome中获得相同的结果(半星).

在chrome:http://jsfiddle.net/Auqj8/

.star {
    font-size: x-large;
    width: 50px;
    display: inline-block;
    color: gray;
}
.star:last-child {
    margin-right: 0;
}
.star:before {
    content: '\2605';
}
.star.on {
    color: gold;
}
.star.half:after {
        content: '\2605';
        color: gold;
        margin-left: -20px;
        width: 10px;
        position: absolute;
        overflow: hidden;
}
Run Code Online (Sandbox Code Playgroud)

在IE中:http://jsfiddle.net/86pqx/

谢谢.

aar*_*len 7

这适用于chrome和IE

.star {
    font-size: x-large;
    width: 50px;
    display: inline-block;
    color: gray;
}
.star:last-child {
    margin-right: 0;
}
.star:before {
    content:'\2605';
}
.star.on {
    color: gold;
}
.star.half:after {
    content:'\2605';
    color: gold;
    position: absolute;
    margin-left: -20px;
    width: 10px;
    overflow: hidden;
}
Run Code Online (Sandbox Code Playgroud)

Chrome:http://jsfiddle.net/Auqj8/1/

IE:http://jsfiddle.net/86pqx/3/

  • 我解决了这个问题(在工作中使用它)。只需将 .star 宽度设置为 24 并将 .star.half:after margin-left 设置为 -24px,宽度设置为 12px,半星就会正确渲染。 (2认同)