0

I have this star rating css. The problem is that I have multiple of these stars ratings on my page and when I click on one of the star rating, others rating is not displayed anymore.

.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>

Stars Id's are unique so I am not sure where is the problem.

Icarus
  • 1,627
  • 7
  • 18
  • 32
zerociudo
  • 357
  • 8
  • 25

0 Answers0