HighDots Forums  

Re: Alternating BG color for long lists

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Re: Alternating BG color for long lists in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Evertjan.
 
Posts: n/a

Default Re: Alternating BG color for long lists - 08-08-2003 , 09:47 AM






Neil Rossi wrote on 08 aug 2003 in
comp.infosystems.www.authoring.stylesheets:
Quote:
Is there a way using CSS, without using client-side or server-side
scripting, to make list backgrounds alternate color with each
successive item in a dropdown list? Is there some other, better way
of displaying long dropdown lists so that the list items are visually
separated? TIA.
Without having to give all the <tr>'s an alternating classname,
javascript [yes, you specified "no script"] does such a nice job:

<table id="mytable" ....

<script>
i=0;
x=mytable.firstChild.childNodes
while(i< x.length) {
if (i % 2)
x(i).style.backgroundColor="#ccc"
else
x(i).style.backgroundColor="#aaa"
i++
}
</script>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.