3
Dear ones, I have stylized my checkbox, but I would like to be able to select more than one option while maintaining the style of CSS which I created.Only due to my CSS rule, this is selecting only for the first item.
@import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
input[type=checkbox] {
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
border: 1px solid #c8c6c6;
width: 15px;
height: 15px;
border-radius: 2px;
}
input[type=checkbox]+label:before {
font-family: FontAwesome;
display: inline-block;
font-size: 19px;
margin: 10px 0px 10px 30px;
}
input[type=checkbox]+label:before:focus {
outline: none;
}
#checkbox {
display: none;
}
#checkbox+label:before {
content: "\f096";
letter-spacing: 10px;
}
#checkbox:checked+label:before {
content: '\f046';
}
<input type="checkbox" id="checkbox" name="">
<label for="checkbox"> Item 1</label>
<br>
<input type="checkbox" id="checkbox" name="">
<label for="checkbox"> Item 2</label>
<br>
<input type="checkbox" id="checkbox" name="">
<label for="checkbox"> Item 3</label>
<br>
<input type="checkbox" id="checkbox" name="">
<label for="checkbox"> Item 4</label>
<br>
<input type="checkbox" id="checkbox" name="">
<label for="checkbox"> Item 5</label>
<br>
I had even done with different ids, but I found too polluted the CSS file. There would be no way to maintain the style without polluting the css?
– Mário Rodeghiero
Sometimes it is possible yes, especially if you use some <script> that will work with the Class and not with the ID. With CSS what is common to do is separates some elements by type comma like this: {
"#checkbox1+label:before, #checkbox2+label:before, etc..."
But with CSS and using<label for="ID>
you can’t improve much.– hugocsl
Got it !! as is more for example, at first I will use this solution. Thank you for the strength!
– Mário Rodeghiero