I just discovered a (to me) weird behavior in CSS.
http://jsfiddle.net/4dL3xv6c/1/
The first box should toggle between "Yes" and empty, while the second should toggle between the opposite of the first box (Yes = No / No = Yes) and empty.
Test scenario 1
Action: Click 1st box, then 2nd, and then 1st again.
Expected result: 1st box is empty and 2nd box is "Yes".
Actual result: 1st box is empty and 2nd box is still "No".
Test scenario 2
Action: Click 2nd box, and then 1st.
Expected result: 1st box is "Yes" and 2nd box is "No".
Actual result: 1st box is "Yes" and 2nd box is also "Yes".
In other words, if I toggle the 1st box, the 2nd box isn't affected - but it should.
Is this the correct behavior of CSS (in Chrome), or is there a bug? Can I make it work as expected?
HTML:
<input id="perm_active" type="checkbox" value="yes" />
<input id="temp_opposite" type="checkbox" value="yes" />
<label for="perm_active" class="btn btn-default btn-primary-toggle"><span></span></label>
<label for="temp_opposite" class="btn btn-default btn-temporary-toggle"><span></span></label>
CSS:
input {
display: none;
}
label {
display: block;
float: left;
width: 50px;
height: 50px;
margin-right: 10px;
line-height: 50px;
text-align: center;
border: 1px solid #ddd;
}
/* Checked + empty */
input:checked + input + label span:before {
content: "Yes";
color: #3c763d;
}
/* Empty + checked */
input:checked + label + label span:before {
content: "Yes";
color: #3c763d;
}
/* Checked + checked */
input:checked + input:checked + label + label span:before {
content: "No";
color: #a94442;
}