how can i create rating system using html css?


I want to create rating system using html and css, how can i achieve it?

I want to achieve like this

Star-rating-system-using-css

 


Asked by:- jaiprakash
2
: 333 At:- 7/9/2017 1:25:36 PM
css html star-rating-system






2 Answers
profileImage Answered by:- vikas_jk

You can create start rating system using HTML radio buttons and CSS, here is the code for rating system

HTML:

<div class="rate">
  <input type="radio" id="star5" name="rate" value="5" />
  <label for="star5" title="text">5 stars</label>
  <input type="radio" id="star4" name="rate" value="4" />
  <label for="star4" title="text">4 stars</label>
  <input type="radio" id="star3" name="rate" value="3" />
  <label for="star3" title="text">3 stars</label>
  <input type="radio" id="star2" name="rate" value="2" />
  <label for="star2" title="text">2 stars</label>
  <input type="radio" id="star1" name="rate" value="1" />
  <label for="star1" title="text">1 star</label>
</div>

CSS:

.rate { 
  float: left;
  height: 46px;
  padding: 0 10px;
}

.rate:not(:checked) > input {
  position: absolute;
  top: -9999px;
}

.rate:not(:checked) > label {
  float: right;
  width: 1em;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  font-size: 30px;
  color: #ccc;
}

.rate:not(:checked) > label:before { content: '? '; }

.rate > input:checked ~ label { color: #ffc700; }

.rate:not(:checked) > label:hover, .rate:not(:checked) > label:hover ~ label { color: #deb217; }

.rate > input:checked + label:hover, .rate > input:checked + label:hover ~ label, .rate > input:checked ~ label:hover, .rate > input:checked ~ label:hover ~ label, .rate > label:hover ~ input:checked ~ label { color: #c59b08; }

You can save it on backend using jQuery Ajax call on Radio button click.

Fiddle link

Original Source: cssscript

2
At:- 7/9/2017 1:55:59 PM


profileImage Answered by:- jaiprakash

Thank you
I have found another working link on codepen, which is similar to your answer

1
At:- 7/9/2017 2:02:59 PM





Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use

Subscribe Now

Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly