How to Implement Star Rating with Review Option – Solution: Star Rating with Review Option using HTML & CSS with source code, demo, and also how you can execute full program easily. To complete the program you need to follow those steps given bellow
Live Demo
Also Helpful –
Responsive Image Comparison Slider
Star Rating with Review Option using HTML & CSS
Description
Back to coding, To complete this program with debugging free code you have to create two files. The first file is to HTML and the second file gonna be CSS for the style part,
index.html
Create an HTML file named ‘index.html‘ and put those codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
<!-- Coding Debugging (https://codingdebugging.com) --> <!DOCTYPE html> <html> <head> <title>Star Rating Review - Coding Debugging</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> <!-- Bootstrap JS --> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> <!-- Google Fonts --> <link href="https://fonts.googleapis.com/css2?family=Baloo+Thambi+2:wght@400;500;600;700;800&display=swap" rel="stylesheet"> <!-- My Stylesheet --> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container p-3"> <div class="row"> <div class="stars text-center"> <div class="col-md-12"> <div class="form-group"> <input type="radio" id="five" name="rate" value="5"> <label for="five"></label> <input type="radio" id="four" name="rate" value="4"> <label for="four"></label> <input type="radio" id="three" name="rate" value="3"> <label for="three"></label> <input type="radio" id="two" name="rate" value="2"> <label for="two"></label> <input type="radio" id="one" name="rate" value="1"> <label for="one"></label> <span class="result"></span> </div> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="textarea"><b>Review</b></label> <textarea class="form-control" id="textarea" rows="4" placeholder="Post your review..."></textarea> </div> </div> <div class="col-md-12 text-right"> <input type="submit" class="btn btn-primary" value="Review"> </div> </div> </div> </body> </html> |
style.css
Create a CSS file named ‘style.css‘ and put those codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
.center{ position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%); } .center .stars{ height: 150px; width: 500px; text-align: center; } .stars input{ display: none; } .stars label{ float: right; font-size: 100px; color: lightgrey; margin: 0 5px; text-shadow: 1px 1px #bbb; } .stars label:before{ content: '★'; } .stars input:checked ~ label{ color: gold; text-shadow: 1px 1px #c60; } .stars:not(:checked) > label:hover, .stars:not(:checked) > label:hover ~ label{ color: gold; } .stars input:checked > label:hover, .stars input:checked > label:hover ~ label{ color: gold; text-shadow: 1px 1px goldenrod; } .stars .result:before{ position: absolute; content: ""; width: 100%; left: 50%; transform: translateX(-47%); bottom: -30px; font-size: 30px; font-weight: 500; color: gold; font-family: 'Poppins', sans-serif; display: none; } .stars input:checked ~ .result:before{ display: block; } .stars #five:checked ~ .result:before{ content: "I love it 😍"; } .stars #four:checked ~ .result:before{ content: "I like it 😀"; } .stars #three:checked ~ .result:before{ content: "It's ok 😑"; } .stars #two:checked ~ .result:before{ content: "I don't like it 😦"; } .stars #one:checked ~ .result:before{ content: "I hate it 😠"; } |
Thank you for visiting!
We appreciate you for your precious time. I hope you are learn something from here! If you have any queries about this coding comment down below we will reply ASAP.
Keep coding, Keep debugging!