开发者

Alternating Row colors for an HTML Fieldset

开发者 https://www.devze.com 2023-04-02 17:19 出处:网络
How can the browser display alternating colors for an HTML fieldset?I have form element开发者_Python百科s that are members of a fieldset, and each row must be an alternating color.Something like this?

How can the browser display alternating colors for an HTML fieldset? I have form element开发者_Python百科s that are members of a fieldset, and each row must be an alternating color.


Something like this?

<style>
label:nth-child(even) {
   background-color: #ddd;
   display:block;
}  
<style>

<fieldset>
   <label> Input <input type="text"></label>
   <label> Input <input type="text"></label>
   <label> Input <input type="text"></label>
   <label> Input <input type="text"></label>
</fieldset>


Here is how I did it...

I have a jquery function...

$("tr:odd").css("background-color", "#e8eef4");

That takes every odd row (I broke down and got table rows :-(... Unfortunately, the suedo-class for tr (tr:nth-child(odd)) doesn't work in IE 8 either... nested parenths ftw btw).

And that my friends is that.

0

精彩评论

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