I have the following css:
@charset "utf-8";
/* CSS Document */
.divCheckBox {
width: 140px;
height: 34px;
}
.divCheckBox .valor {
display: inline-block;
line-height: 34px;
top: 0;
}
.divCheckBox .checkBox {
display: none;
}
.divCheckBox .labelCheckBox {
width: 60px;
height: 34px;
background-color: #CCC;
display: block;
cursor: pointer;
border-radius: 34px;
display: inline-block;
}
.divCheckBox .labelCheckBox:before {
width: 26px;
height: 26px;
margin: 4px;
background-color: #FFF;
content: "";
display: inline-block;
-webkit-transition: .4s;
transition: .4s;
border-radius: 50%;
vertical-align: middle;
}
.divCheckBox .checkBox:checked + .divCheckBox .labelCheckBox {
background-color: blue;
}
.divCheckBox .checkBox:checked + .divCheckBox .labelCheckBox:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
And the following html
<!DOCTYPE html>
<html>
<head>
<title>CheckBox Round</title>
<link type="text/css" rel="stylesheet" href="_css/checkBoxRound.css" />
</head>
<body>
<form action="?" method="post">
<div class="divCheckBox">
<label class="valor">SIM</label>
<input type="checkbox" name="ca" id="ca" class="checkBox">
<label for="ca" class="labelCheckBox"></label>
<label class="valor">NÃO </label>
</div>
<br />
<input type="submit">
</form>
</body>
</html>
When I squeeze, and click on the labelCheckBox, I should technically change its color to blue and the ball inside run to the right. But it's not happening.
However, although the class name is correct, if I remove it
.divCheckBox
From the structure below
.divCheckBox .checkBox:checked + .divCheckBox .labelCheckBox {
background-color: blue;
}
.divCheckBox .checkBox:checked + .divCheckBox .labelCheckBox:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
Getting,
.checkBox:checked + .labelCheckBox {
background-color: blue;
}
.checkBox:checked + .labelCheckBox:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
Then it works.
Where will this error be?