星级html,css [英] star rating html, css
本文介绍了星级html,css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我确实被困在这里,需要帮助.如何为每个按钮使用标签?有人可以帮我完成此星级评分代码吗?对于每个按钮,请仅使用一个标签,并根据需要使用任意数量的跨度标签."所有帮助将不胜感激,谢谢.
I did stuck here and need help. How can I use a tag for for each button? Can somebody help me to finish this star rating code? "For each button use only a single a tag, with as many span tags as you need." All help will be appreciated, thanks.
这是我的代码:
h2 {
text-align: left;
padding-left: 20px;
color: white;
font-size: 30px;
font-family: Calibri;
}
#box {
outline: 10px double;
outline-color: black;
outline-offset: 1px;
background: steelblue;
width: 450px;
margin-top: 40px;
margin-left: 45px;
text-align: right;
display: inline-block;
}
.star-icon {
color: ghostwhite;
font-size: 2em;
position: relative;
}
.star-icon.full:before {
color: yellow;
content: '\2605';
position: absolute;
left: 0;
}
<div id="box">
<h2>Rating</h2>
<div class="position">
<span class="star-icon full">☆</span>
<span class="star-icon full">☆</span>
<span class="star-icon ">☆</span>
<span class="star-icon ">☆</span>
<span class="star-icon">☆</span>
</div>
</div>
推荐答案
HTML代码:
<fieldset class="rating">
<input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label>
<input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label>
<input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label>
<input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label>
<input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label>
<input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label>
<input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label>
<input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label>
<input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label>
<input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label>
css文件:
@import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
fieldset, label { margin: 0; padding: 0; }
body{ margin: 20px; }
h1 { font-size: 1.5em; margin: 10px; }
.rating {
border: none;
float: left;
}
.rating > input { display: none; }
.rating > label:before {
margin: 5px;
font-size: 1.25em;
font-family: FontAwesome;
display: inline-block;
content: "\f005";
}
.rating > .half:before {
content: "\f089";
position: absolute;
}
.rating > label {
color: #ddd;
float: right;
}
.rating > input:checked ~ label, /* show gold star when clicked */
.rating:not(:checked) > label:hover, /* hover current star */
.rating:not(:checked) > label:hover ~ label { color: #FFD700; } /* hover previous stars in list */
.rating > input:checked + label:hover, /* hover current star when changing rating */
.rating > input:checked ~ label:hover,
.rating > label:hover ~ input:checked ~ label, /* lighten current selection */
.rating > input:checked ~ label:hover ~ label { color: #FFED85; }
请检查此代码可能有帮助
Kindly check this code might be helpful
这篇关于星级html,css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文