Reputation: 939
Good night.
Hello guys, I have a question: I have a Radio Button Star Rating Widget in my page, at the moment the stars are close to each other and I need to separate them (fill the div's 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;
}
NOTE: When I try to use Bootstrap Grid or to use any div tag around an input only one star will be filled.
What can I do to fix this ?
Thank you very much.
Upvotes: 1
Views: 549
Reputation: 92
You have to make that stars block in the one div so that it will work in all devices.
HTML:
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<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>
</div>
</div>
CSS:
.stars-div {
padding-top: 9.8%;
padding-left: 1%
}
.stars {
display: inline-block;
width: 100%
}
.star-input {
display: none;
}
.star-icon {
float: right;
padding: 1%;
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;
}
Upvotes: 0