Source Code: (back to article)
<!DOCTYPE html>
<html>
<head>
<title>Stylez une case à cocher à l'aide de CSS</title>
<style>
h1 {
color: #8ebf42;
}
.script {
display: block;
position: relative;
padding-left: 45px;
margin-bottom: 15px;
cursor: pointer;
font-size: 20px;
}
/* Hide the default checkbox */
input[type="checkbox"] {
visibility: hidden;
}
/* creating a custom checkbox based on demand */
.w3docs {
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: black;
}
/* specify the background color to be shown when hovering over checkbox */
.script:hover input ~ .w3docs {
background-color: orange;
}
/* specify the background color to be shown when checkbox is active */
.script input:active ~ .w3docs {
background-color: red;