All, I have a checkbox that I applied the following CSS style to:
-webkit-appearance: none;
This same code is on some text fields I have and these still continue to work just fine. Why is this functionality causing the checkbox to not allowed to be checked?
I like the styling of the checkbox this way but still need the functionality to work. If I change the code to:
-webkit-appearance: checkbox;
It displays the standard checkbox. Any ideas? Here is a JS Fiddle for demonstration purposes: http://jsfiddle.net/VWC76/
Clicks on either of the checkboxes will be ignored because of e. preventDefault(); Whereas, e. stopPropagation(); will prevent the bubbling up of the click event to the parent table.
A checkbox cannot be checked in CSS, unfortunately. It relies on the checked attribute of the input element, and attributes cannot be modified via CSS. Alternatively, you could look into a JavaScript solution, but of course the best way would be to edit the HTML directly.
You can put a transparent div on top of the checkbox to make it un-clickable by toggling a class on the parent object.
prop() and is() method are the two way by which we can check whether a checkbox is checked in jQuery or not. prop(): This method provides an simple way to track down the status of checkboxes. It works well in every condition because every checkbox has checked property which specifies its checked or unchecked status.
You just nuked all styles of checkbox on WebKit, so yes you can't see whether they're checked or not (they still are, it just isn't visible to us sighted people without a screen reader).
You need to style the checked state with the :checked
pseudo: http://jsfiddle.net/VWC76/450/
input[type=checkbox]:checked {
background-color: red;
/* or whatever styles you want depending on your design */
/* be as obvious as possible that it's a checkbox and that it's checked! */
}
EDIT:
appearance:none
now exists outside of WebKit/Blink (caniuse). Just use Autoprefixer if you've better to do than adding prefixes by hand :)EDIT 2:
You need to add a input[type=checkbox]:checked
input[type=checkbox]:checked {
background: #BADA55;
}
If this is what you're looking for?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With