我需要在CSS中创建评级星,到目前为止我有两个要求,
-
半彩色星形。
-
有边框但身体透明的星星。
到目前为止,我可以用CSS创建一个全彩色的星星。但有了这个结构,我无法达到上述要求。
这就是我现在拥有的,我跟着这个
ANSWER
供我参考
.star {
position: relative;
display: inline-block;
width: 0;
height: 0;
margin-left: .9em;
margin-right: .9em;
margin-bottom: 1.2em;
border-right: .3em solid transparent;
border-bottom: .7em solid #FC0;
border-left: .3em solid transparent;
/* Controlls the size of the stars. */
font-size: 24px;
}
.star:before,
.star:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
top: .6em;
left: -1em;
border-right: 1em solid transparent;
border-bottom: .7em solid #FC0;
border-left: 1em solid transparent;
transform: rotate(-35deg);
}
.star:after {
transform: rotate(35deg);
}
<p>
<i class="star"></i>
<i class="star half"></i>
<i class="star transparent"></i>
</p>