Skip to content

Commit ab1d6c9

Browse files
committed
add code for generating interactive rating stars
1 parent c01e993 commit ab1d6c9

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,15 @@ Please be aware that the demos may exhibit significant accessibility issues, suc
845845
=======
846846
 
847847

848+
## <a id="Rating Star"></a>Rating Star
849+
850+
![img_source](images/rating-star.png)
851+
852+
**[⬆ back to top](#quick-links)**
853+
=======
854+
&nbsp;
855+
856+
848857
---
849858

850859
## Contributors

Rating-Star/index.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<html>
2+
3+
<head>
4+
<meta charset="UTF-8">
5+
<link rel="stylesheet" type="text/css" href="style.css">
6+
<title>Star rating</title>
7+
</head>
8+
9+
<body>
10+
<div class="rate">
11+
<input type="radio" id="star5" name="rate" value="5" />
12+
<label for="star5" title="text">5 stars</label>
13+
<input type="radio" id="star4" name="rate" value="4" />
14+
<label for="star4" title="text">4 stars</label>
15+
<input type="radio" id="star3" name="rate" value="3" />
16+
<label for="star3" title="text">3 stars</label>
17+
<input type="radio" id="star2" name="rate" value="2" />
18+
<label for="star2" title="text">2 stars</label>
19+
<input type="radio" id="star1" name="rate" value="1" />
20+
<label for="star1" title="text">1 star</label>
21+
</div>
22+
</body>
23+
24+
</html>

Rating-Star/style.css

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
*{
2+
margin: 0;
3+
padding: 0;
4+
}
5+
.rate {
6+
float: left;
7+
height: 46px;
8+
padding: 0 10px;
9+
}
10+
.rate:not(:checked) > input {
11+
position:absolute;
12+
top:-9999px;
13+
}
14+
.rate:not(:checked) > label {
15+
float:right;
16+
width:1em;
17+
overflow:hidden;
18+
white-space:nowrap;
19+
cursor:pointer;
20+
font-size:30px;
21+
color:#ccc;
22+
}
23+
.rate:not(:checked) > label:before {
24+
content: '★ ';
25+
}
26+
.rate > input:checked ~ label {
27+
color: #ffc700;
28+
}
29+
.rate:not(:checked) > label:hover,
30+
.rate:not(:checked) > label:hover ~ label {
31+
color: #deb217;
32+
}
33+
.rate > input:checked + label:hover,
34+
.rate > input:checked + label:hover ~ label,
35+
.rate > input:checked ~ label:hover,
36+
.rate > input:checked ~ label:hover ~ label,
37+
.rate > label:hover ~ input:checked ~ label {
38+
color: #c59b08;
39+
}

images/rating-star.png

8.21 KB
Loading

0 commit comments

Comments
 (0)