Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Star rating using pure css

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 173
    Comment on it

    Hi all, Below is an example, how to make star rating using pure css.

    CSS -

    .rate {
        float: left;
    }
    .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;
    }
    

    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>
    

    Output-

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: