【发布时间】:2016-03-09 02:08:45
【问题描述】:
您好,
我正在尝试建立一个 5 星评级表格,我想要 3 行 5 星评级。这是我所拥有的:
.ratingLabel {
font-family: 'Montserrat Light',Helvetica,sans-serif;
padding: 8px 0;
float: left;
color: #A9A9A9;
}
.rating {
float: right;
}
.rating input {
display: none;
}
.rating label {
color: #ddd;
float: right;
}
.rating label:before {
margin: 5px;
font-size: 20px;
font-family: fontAwesome;
display: inline-block;
content: "\f005";
}
.rating .half:before {
content: "\f089";
position: absolute;
}
.rating > input:checked ~ label,.rating:not(:checked) > label:hover,.rating:not(:checked) > label:hover ~ label {
color: #FFD700;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="form-group col-lg-8 col-md-8 col-s-8 col-xs-12">
<label class="ratingLabel">Friendly advisor:</label>
<div class="rating">
<input id="star5" name="rating" type="radio" value="5"/>
<label for="star5" class="full"></label>
<input id="star4.5" name="rating" type="radio" value="4.5"/>
<label for="star4.5" class="half"></label>
<input id="star3" name="rating" type="radio" value="3"/>
<label for="star3" class="full"></label>
<input id="star3.5" name="rating" type="radio" value="3.5"/>
<label for="star3.5" class="half"></label>
<input id="star2" name="rating" type="radio" value="2"/>
<label for="star2" class="full"></label>
<input id="star2.5" name="rating" type="radio" value="2.5"/>
<label for="star2.5" class="half"></label>
<input id="star1" name="rating" type="radio" value="1"/>
<label for="star1" class="full"></label>
<input id="star1.5" name="rating" type="radio" value="1.5"/>
<label for="star1.5" class="half"></label>
<input id="star0" name="rating" type="radio" value="0"/>
<label for="star0" class="full"></label>
<input id="star0.5" name="rating" type="radio" value="0.5"/>
<label for="star0.5" class="half"></label>
</div>
</div>
<div class="form-group col-lg-8 col-md-8 col-s-8 col-xs-12">
<label class="ratingLabel">Call line quality:</label>
<div class="rating">
<input id="star5" name="rating" type="radio" value="5"/>
<label for="star5" class="full"></label>
<input id="star4.5" name="rating" type="radio" value="4.5"/>
<label for="star4.5" class="half"></label>
<input id="star3" name="rating" type="radio" value="3"/>
<label for="star3" class="full"></label>
<input id="star3.5" name="rating" type="radio" value="3.5"/>
<label for="star3.5" class="half"></label>
<input id="star2" name="rating" type="radio" value="2"/>
<label for="star2" class="full"></label>
<input id="star2.5" name="rating" type="radio" value="2.5"/>
<label for="star2.5" class="half"></label>
<input id="star1" name="rating" type="radio" value="1"/>
<label for="star1" class="full"></label>
<input id="star1.5" name="rating" type="radio" value="1.5"/>
<label for="star1.5" class="half"></label>
<input id="star0" name="rating" type="radio" value="0"/>
<label for="star0" class="full"></label>
<input id="star0.5" name="rating" type="radio" value="0.5"/>
<label for="star0.5" class="half"></label>
</div>
</div>
<div class="form-group col-lg-8 col-md-8 col-s-8 col-xs-12">
<label class="ratingLabel">Overall satisfaction:</label>
<div class="rating">
<input id="star5" name="rating" type="radio" value="5"/>
<label for="star5" class="full"></label>
<input id="star4.5" name="rating" type="radio" value="4.5"/>
<label for="star4.5" class="half"></label>
<input id="star3" name="rating" type="radio" value="3"/>
<label for="star3" class="full"></label>
<input id="star3.5" name="rating" type="radio" value="3.5"/>
<label for="star3.5" class="half"></label>
<input id="star2" name="rating" type="radio" value="2"/>
<label for="star2" class="full"></label>
<input id="star2.5" name="rating" type="radio" value="2.5"/>
<label for="star2.5" class="half"></label>
<input id="star1" name="rating" type="radio" value="1"/>
<label for="star1" class="full"></label>
<input id="star1.5" name="rating" type="radio" value="1.5"/>
<label for="star1.5" class="half"></label>
<input id="star0" name="rating" type="radio" value="0"/>
<label for="star0" class="full"></label>
<input id="star0.5" name="rating" type="radio" value="0.5"/>
<label for="star0.5" class="half"></label>
</div>
</div>
正如您从以下 link 中看到的live,选择根本不起作用。尝试以不同的方式命名 3 行并赋予它们不同的 ID,但仍然无效。
【问题讨论】:
-
属性
id不能包含. -
看看这个,可能对你有帮助stackoverflow.com/questions/30991572/…
-
您的代码似乎有问题。一旦我尝试重写您的代码,它就可以工作。不是吗?