Define css for checkbox
Is it possible to define css style for checkbox in a form without define id and class for it开发者_如何转开发? I know i can use
input {css...}
but i will effect all the inputs in the form.
input[type="checkbox"]{...}
There is still some issue with old browsers not recognizing it (IE6 for example) but there are work-arounds to deal with it, if that support is needed.
Like this, using attribute selectors:
input[type="checkbox"] {
css...
}
Just be aware that IE6 does not support this. Apart from that, browser support is pretty good.
In addition to attribute selectors, you can, in some newer browsers, use several different pseudo-classes, for example:
<form>
<input type="text" />
<input type="text" />
<input type="text" />
</form>
to target the second input:
input:nth-child(n) {
css-property: value;
}
精彩评论