Em mới học html với css. Em muốn khi checkbox checked thì nó tạo ra hiệu ứng line-through nhưng mà r làm mãi k ra. Nhờ mấy pro chỉ e với
code css:
body {
font-size: 1.1em;
color: #111;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: #ecf0f1;
}
.container {
font-weight: 600;
width: 200px;
height: 200px;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
}
input[type='checkbox'] {
display: none;
}
.check-container {
display: inline-block;
position: relative;
width: 200px;
height: 50px;
}
input[type='checkbox'] + label {
z-index: 15;
position: absolute;
left: 0;
top: -1px;
bottom: 10px;
right: 10px;
transition: all 0.3s ease;
cursor: pointer;
width: 20px;
border: 4px solid #444;
height: 20px;
}
.tag {
margin-left: 40px;
}
input[type='checkbox']:checked + label {
transition: all 0.3s ease;
display: inline-block;
width: 20px;
height: 20px;
border-top-color: transparent;
border-right-color: transparent;
border-bottom-color: #2ecc7a;
border-left-color: transparent;
transform: rotate(-50deg) translate(5px, -9px);
}
input[type=checkbox]:checked + label::before{
content: "";
position: absolute;
right: 0;
bottom: -3px;
height: 15px;
width: 100%;
border-left: 4px solid #2ecc7a;
}
code html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Checkbox</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="check-container">
<input type="checkbox" name="cb1" id="checkbox1">
<label for="checkbox1"></label>
<span class="tag">
Hello everyone
</span>
</div>
<div class="check-container">
<input type="checkbox" name="cb2" id="checkbox2">
<label for="checkbox2"></label>
<span class="tag">
Microsoft Windows
</span>
</div>
<div class="check-container">
<input type="checkbox" name="cb3" id="checkbox3">
<label for="checkbox3"></label>
<span class="tag">Ubuntu or Linux</span>
</div>
</div>
</body>
</html>