多星评级css

时间:2018-02-07 13:31:41

标签: html css

我有这个星级评分css。问题是我在我的页面上有多个这些星级评分,当我点击其中一个星级评级时,其他评级不再显示。

.rating > input { display: none; } 
.rating > label:before { 
    margin: none;
    font-size: 1.25em;
    font-family: FontAwesome;
    display: inline-block;
    content: "\f005";
}

.rating > .half:before { 
    content: "\f089";
    position: absolute;
}

.rating > label { 
    color: #ddd; 
    float: right; 
}
/**** CSS Magic to Highlight Stars on Hover ****/

.rating > input:checked ~ label, /* show gold star when clicked */
.rating:not(:checked) > label:hover, /* hover current star */
.rating:not(:checked) > label:hover ~ label, .mark { color: #FFD700;  } /* hover previous stars in list */
.rating > input { display: none; } 
.rating > label:before { 
    .rating > input:checked + label:hover, /* hover current star when changing rating */
    .rating > input:checked ~ label:hover,
    .rating > label:hover ~ input:checked ~ label, /* lighten current selection */
    .rating > input:checked ~ label:hover ~ label { color: #FFED85;  }

HTML:

<fieldset class="rating" data-reviewId="{{$review->id}}" data-rating="{{$review->getAverage()}}" >
  <input type="radio" id="star{{$review->id}}_5" class="rate" name="rating" value="5" /><label class = "star" for="star{{$review->id}}_5" title="Awesome - 5 stars"></label>
  <input type="radio" id="star{{$review->id}}_4" class="rate" name="rating" value="4" /><label class = "star" for="star{{$review->id}}_4" title="Pretty good - 4 stars"></label>
  <input type="radio" id="star{{$review->id}}_3" class="rate" name="rating" value="3" /><label class = "star" for="star{{$review->id}}_3" title="Meh - 3 stars"></label>
  <input type="radio" id="star{{$review->id}}_2" class="rate" name="rating" value="2" /><label class = "star" for="star{{$review->id}}_2" title="Kinda bad - 2 stars"></label>
  <input type="radio" id="star{{$review->id}}_1" class="rate" name="rating" value="1" /><label class = "star" for="star{{$review->id}}_1" title="Sucks big time - 1 star"></label>
</fieldset>

明星身份证是独一无二的,所以我不确定问题出在哪里。

0 个答案:

没有答案