I am building a custom check box, the functionality is almost there but the styling has a way to go.
I have a few problems,
Im afraid i cant seem to center the check without using padding left of position left.
HTML
<label for='product-45-45'>
<input type='checkbox' style="float:left;" id='product-45-45' />
<div class="accord-text">
<strong>header:</strong> sub text
<strong>more text!</strong>
</div>
</label>
CSS
input[type=checkbox] {
display: none;
}
input[type=checkbox] + .accord-text:before {
width: 30px;
height: 30px;
border-radius: 200%;
background-color: #d6e4ec;
border: 1px solid #000;
display: block;
font-size: 150%;
font-weight: 900;
content: "";
color: green;
}
input[type=checkbox]:checked + .accord-text:before {
display: table;
content: "\2713";
}
text-align: center; when checkbox ic checked, and remove style="float:left;" from checkboxaccord-text div and put it outside..row{
display: flex;
flex-direction: row;
}
input[type=checkbox] {
display: none;
}
input[type=checkbox] + .accord-text:before {
width: 30px;
height: 30px;
border-radius: 200%;
background-color: #d6e4ec;
border: 1px solid #000;
display: block;
font-size: 140%;
font-weight: 900;
content: "";
color: green;
}
input[type=checkbox]:checked + .accord-text:before {
display: table;
content: "\2713";
text-align: center;
}
<div class="row">
<label for='product-45-45'>
<input type='checkbox' style="float:left;" id='product-45-45' />
<div class="accord-text">
</div>
</label>
<strong>header:</strong> sub text
<strong>more text!</strong>
</div>
Check with this snippet also i have fixed the height issue when we checked ,
Add display:block and max-height to this input[type=checkbox]:checked + .accord-text:before
input[type=checkbox] {
display: none;
}
label {
float:left;
}
input[type=checkbox] + .accord-text:before {
width: 30px;
height: 30px;
border-radius: 200%;
background-color: #d6e4ec;
border: 1px solid #000;
display: block;
font-size: 150%;
font-weight: 900;
content: "";
color: green;
text-align:center;
max-height:30px;
}
input[type=checkbox]:checked + .accord-text:before {
display: table;
content: "\2713";
max-height:30px;
display:block;
}
span {
float:left;
padding-left:5px;
}
<label for='product-45-45'>
<input type='checkbox' style="float:left;" id='product-45-45' />
<div class="accord-text"></div>
</label>
<span><strong>header:</strong> sub text
<strong>more text!</strong>
</span>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With