Knowledge base
Knowledge base
Knowledge base
 
Programmazione - CSS
Personalizzare i Checkbox con i CSS

HTML

<div>
<input type="checkbox" id="test1" />
<label for="test1">Uno</label>
</div>
<div style="margin-top:10px;">
<input type="checkbox" id="test2" checked="checked" />
<label for="test2">Due</label>
</div>
<div style="margin-top:10px;">
<input type="checkbox" id="test3" checked="checked" disabled="disabled" />
<label for="test3">Tre</label>
</div>
<div style="margin-top:10px;">
<input type="checkbox" id="test4" disabled="disabled" />
<label for="test4">Quattro</label>
</div>

 

 

CSS

/* Base for label styling */
[type="checkbox"]:not(:checked),
[type="checkbox"]:checked {
position: absolute;
left: -9999px;
}
[type="checkbox"]:not(:checked) + label,
[type="checkbox"]:checked + label {
position: relative;
padding-left: 25px;
cursor: pointer;
}

/* checkbox aspect */
[type="checkbox"]:not(:checked) + label:before,
[type="checkbox"]:checked + label:before {
content: '';
position: absolute;
left:0; top: 2px;
width: 17px; height: 17px;
border: 1px solid #aaa;
background: #f8f8f8;
border-radius: 3px;
box-shadow: inset 0 1px 3px rgba(0,0,0,.3)
}
/* checked mark aspect */
[type="checkbox"]:not(:checked) + label:after,
[type="checkbox"]:checked + label:after {
content: '✔';
position: absolute;
top: 3px; left: 4px;
font-size: 18px;
line-height: 0.8;
color: #09ad7e;
transition: all .2s;
}
/* checked mark aspect changes */
[type="checkbox"]:not(:checked) + label:after {
opacity: 0;
transform: scale(0);
}
[type="checkbox"]:checked + label:after {
opacity: 1;
transform: scale(1);
}
/* disabled checkbox */
[type="checkbox"]:disabled:not(:checked) + label:before,
[type="checkbox"]:disabled:checked + label:before {
box-shadow: none;
border-color: #bbb;
background-color: #ddd;
}
[type="checkbox"]:disabled:checked + label:after {
color: #999;
}
[type="checkbox"]:disabled + label {
color: #aaa;
}
/* accessibility */
[type="checkbox"]:checked:focus + label:before,
[type="checkbox"]:not(:checked):focus + label:before {
border: 1px dotted blue;
}

/* hover style just for information */
label:hover:before {
border: 1px solid #4778d9!important;
}

 

 

COMPUTER PLUS srl
Via Fernando Santi 5
60035 JESI (AN)
Tel. 0731 214634
Fax 0731 221903
info@computerplus.it
info@pec.computerplus.it
Chi Siamo
Dove Siamo
Lo Staff
Contatti
Company Profile
Richiesta assistenza
Supporto
 
Effettua i tuoi pagamenti online!
È facile e veloce!
 
Inoltre puoi utilizzare anche il nostro POS virtuale per pagare anticipi o fatture ⇨ pos.computerplus.it
© Copyright 2024 Computer Plus srl | P.Iva IT01538200427 | Termini e Condizioni> | Politica sulla privacy | Informativa sui cookies