晚安
大家好,我有一个问题:我的页面中有一个单选按钮星级评分小部件,此时星星彼此靠近,我需要将它们分开(填充 div 的 witdh)。
HTML
<div class="stars-div">
<div class="stars">
<input class="star-input star-5" id="star-5" type="radio" name="star"/>
<label class="star-icon star-5" for="star-5"></label>
<input class="star-input star-4" id="star-4" type="radio" name="star"/>
<label class="star-icon star-4" for="star-4"></label>
<input class="star-input star-3" id="star-3" type="radio" name="star"/>
<label class="star-icon star-3" for="star-3"></label>
<input class="star-input star-2" id="star-2" type="radio" name="star"/>
<label class="star-icon star-2" for="star-2"></label>
<input class="star-input star-1" id="star-1" type="radio" name="star"/>
<label class="star-icon star-1" for="star-1"></label>
</div>
</div>
CSS
.stars-div {
padding-top: 9.8%;
padding-left: 5%
}
.stars {
display: inline-block;
width: 100%
}
.star-input {
display: none;
}
.star-icon {
float: right;
padding: 10px;
font-size: 50px;
}
.star-input:checked ~ .star-icon:before {
content: '\f005';
color: #FD4;
}
.star-icon:hover:before, .star-icon:hover ~ .star-icon:before {
content: '\f005';
color: #ffea8e;
}
.star-icon:before {
content: '\f006';
font-family: FontAwesome;
}
注意:当我尝试使用 Bootstrap Grid 或在输入周围使用任何 div 标签时,只会填充一颗星。
我该怎么做才能解决这个问题?
非常感谢。
最佳答案
看这里 jsfiddle
只需将 div 分成 5 个部分(您有 5 颗星)
另外一个问题(加星号)可以举个例子吗?
代码:
.star-icon {
float: right;
padding: 10px;
font-size: 50px;
box-sizing:border-box;
width:20%;
}
关于html - CSS 星级评分分离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38138659/