1
Hello, I’m studying CSS3 and, in a given tutorial, I analyzed it all, and did not understand the point where the ::before
was used together with the checkbox, in which the property was added content
.
Why in the first use of ::before
with the pseudo-class :checked
it stylizes the value of content
and does not style the checkbox itself?
Follows code:
body {
margin: 5px;
padding: 0;
background: #262626;
}
#botoes {
position: absolute;
width: 100px;
color: #fff;
margin: 5px;
}
#botoes input[type=checkbox]::before {
content: '';
position: absolute;
width: 40px;
height: 40px;
top: 0;
left: 0;
border-radius: 50%;
background: #000;
transition: .1s;
transform: scale(1.1);
box-shadow: 0 0px 15px #ffffff;
}
#botoes input[type=checkbox] {
position: relative;
background: #b9b9c8;
width: 80px;
height: 40px;
border: none;
float: right;
border-radius: 20px;
-webkit-appearance: none;
margin-bottom: 15%;
outline: none;
}
#botoes input:checked[type=checkbox]::before {
left: 40px;
}
#botoes input:checked[type=checkbox] {
background: dodgerBlue;
}
<html lang="pt-br">
<head>
<title>Test Toogle With Pure CSS</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="CSS/xxxxxxxx.css">
</head>
<div class="box" id="box">
</div>
<body>
<div id="botoes">
Hidden Rings
<input type="checkbox"> Collision Rings
<input type="checkbox">
</div>
</body>
</html>
You want to know why on
elemento::before
need to put thecontent
and in theelemento
in itself not? If that is so, it is because thecontent
of the element itself is defined in HTML, but the taginput
is a little different– Costamilam
No, Guilherme, look at the second paragraph of my question: why does CSS style the content of the element (the content) and not the element itself, understand? See all the css code posted (with scrool), ok?
– Fernandes