Pure CSS Star Rating Widget
Formulaire CSS + Font awesome

Formulaire d’évaluation avec étoile en pure CSS.

Html :

  1. <h1>Pure CSS Star Rating Widget</h1>
  2. <fieldset class="rating">
  3.     <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label>
  4.     <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label>
  5.     <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label>
  6.     <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label>
  7.     <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label>
  8.     <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label>
  9.     <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label>
  10.     <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label>
  11.     <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label>
  12.     <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label>

Télécharger

CSS :

  1. @import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
  2.  
  3. fieldset, label { margin: 0; padding: 0; }
  4. body{ margin: 20px; }
  5. h1 { font-size: 1.5em; margin: 10px; }
  6.  
  7. /****** Style Star Rating Widget *****/
  8.  
  9. .rating {
  10.   border: none;
  11.   float: left;
  12. }
  13.  
  14. .rating > input { display: none; }
  15. .rating > label:before {
  16.   margin: 5px;
  17.   font-size: 1.25em;
  18.   font-family: FontAwesome;
  19.   display: inline-block;
  20.   content: "\f005";
  21. }
  22.  
  23. .rating > .half:before {
  24.   content: "\f089";
  25.   position: absolute;
  26. }
  27.  
  28. .rating > label {
  29.   color: #ddd;
  30.  float: right;
  31. }
  32.  
  33. /***** CSS Magic to Highlight Stars on Hover *****/
  34.  
  35. .rating > input:checked ~ label, /* show gold star when clicked */
  36. .rating:not(:checked) > label:hover, /* hover current star */
  37. .rating:not(:checked) > label:hover ~ label { color: #FFD700;  } /* hover previous stars in list */
  38.  
  39. .rating > input:checked + label:hover, /* hover current star when changing rating */
  40. .rating > input:checked ~ label:hover,
  41. .rating > label:hover ~ input:checked ~ label, /* lighten current selection */
  42. .rating > input:checked ~ label:hover ~ label { color: #FFED85;  }

Télécharger

source Pure CSS Star Rating Widget


Pierrox

P.-S.

Crédit : James Barnett