开发者

Define css for checkbox

开发者 https://www.devze.com 2023-03-27 09:33 出处:网络
Is it possible to define css style for checkbox in a form without define id and class for it开发者_如何转开发? I know i can use

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消