Reputation: 1447
I'm trying to change color of first two stars in fontawesome star rating at http://fortawesome.github.io/Font-Awesome/examples/
I have assigned a class to first & second span but it is not working
My html is
<span class="rating">
<span class="star filled"></span>
<span class="star filled"></span>
<span class="star"></span>
<span class="star"></span>
<span class="star"></span>
</span>
and my css is
.rating {
unicode-bidi:bidi-override;
direction:rtl;
font-size:30px;
}
.rating span.star {
font-family:FontAwesome;
font-weight:normal;
font-style:normal;
display:inline-block;
}
.rating span.star:hover {
cursor:pointer;
}
.rating span.star:before {
content:"\f006";
padding-right:5px;
color:#999999;
}
.rating span.star:hover:before, .rating span.star:hover~span.star:before {
content:"\f005";
color:#e3cf7a;
}
.filled{ color:#e3cf7a; }
JSFIDDLE http://jsfiddle.net/code_snips/ttyYD/
Upvotes: 4
Views: 11673
Reputation: 46
.filled
is not specific enough, use span.star.filled
:before
, so use span.star.filled:before{ color:#e3cf7a; }
content:"\f005";
, too.But this is probably still not what you want; you might not have noticed, but the .rating
class changes the text direction (unicode-bidi:bidi-override; direction:rtl;
).
So, you'd need to apply the filled
class to the last two span tags.
Upvotes: 3
Reputation: 6209
Try this one
Jsfiddle
Script:
$('.rating span.star').click(function(){
var total=$(this).parent().children().length;
var clickedIndex=$(this).index();
$('.rating span.star').removeClass('filled');
for(var i=clickedIndex;i<total;i++){
$('.rating span.star').eq(i).addClass('filled');
}
});
Upvotes: 3
Reputation: 610
.rating{unicode-bidi:bidi-override;direction:rtl;font-size:10px;} .rating span.star{font-family:FontAwesome;font-weight:normal;font-style:normal;display:inline-block} .rating span.star:hover{cursor:pointer} .rating span.star:before{content:"\f006";padding-right:5px;color:#999} .rating span.star:hover:before,.rating span.star:hover~span.star:before{content:"\f005";color:#e3cf7a} .rating span.star.filled {} .rating span.star.filled:before{content:"\f005";color:#e3cf7a; }
<span class="rating" style="font-size:13px;"><span class="star"></span><span class="star"></span><span class="star filled"></span><spanclass="star filled"></span><span class="star filled"></span></span>
Upvotes: 0