html - CSS 星级评分分离

标签 html twitter-bootstrap css twitter-bootstrap-3

晚安

大家好,我有一个问题:我的页面中有一个单选按钮星级评分小部件,此时星星彼此靠近,我需要将它们分开(填充 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/

相关文章:

javascript - 如果调整视口(viewport)大小,如何显示之前隐藏的 div?

html - Foundation 6 顶部栏菜单图标

jquery - 谷歌浏览器中不显示滚动条

javascript - jquery .html 仅在 Chrome 中重新加载页面

html - 无法使 html 表格列固定大小(不能根据数据自动扩展)

javascript - Bootstrap 轮播动画从上到下而不是从左到右

css - 用 LESS 覆盖 Bootstrap Navbar 下拉菜单颜色?

html - 在 NODE.JS 中链接 CSS、HTML

javascript - 在 html 页面上显示大图像后,如何获取大图像的宽度和高度?

html - Google Chrome (Windows) - 如何添加缺失的语音合成声音