Skip to content

Instantly share code, notes, and snippets.

@tcelestino
Created December 3, 2018 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcelestino/25cb130879c5688d40cf0b49a723af3e to your computer and use it in GitHub Desktop.
Save tcelestino/25cb130879c5688d40cf0b49a723af3e to your computer and use it in GitHub Desktop.
customize checkbox
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Checkbox customizado</title>
<style>
label {
display: block;
position: relative;
padding-left: 30px;
margin-bottom: 15px;
cursor: pointer;
font-size: 18px;
}
label input {
position: absolute;
z-index: -1;
opacity: 0;
}
div {
position: absolute;
top: 2px;
left: 0;
height: 20px;
width: 20px;
background: #e6e6e6;
}
label:hover input ~ div,
label input:focus ~ div {
background: #ccc;
}
label input:checked ~ div {
background: #89b736;
}
label:hover input:not([disabled]):checked ~ div,
label input:checked:focus ~ div {
background: #89b736;
}
label input:disabled ~ div {
background: #e6e6e6;
opacity: 0.6;
pointer-events: none;
}
div:after {
content: '';
position: absolute;
display: none;
}
label input:checked ~ div:after {
display: block;
}
label div:after {
left: 8px;
top: 4px;
width: 3px;
height: 8px;
border: solid #fff;
border-width: 0 2px 2px 0;
transform: rotate(45deg);
}
label input:disabled ~ div:after {
border-color: #7b7b7b;
}
</style>
</head>
<body>
<label class="">Aceito receber informações e novidades pelo whatsapp
<input type="checkbox" checked="checked"/>
<div></div>
</label>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment