Previous Message
Next Message

alternating colors of list items in IE

Sent by Jukka K. Korpela on 13 March 2007 21:09


On Tue, 13 Mar 2007, David Agnew wrote:

> #containAbt .features li {
>  background-color: #F7EFD5;
> }
> /* darker shades for alternate li's */
> #containAbt .features li+li, #containAbt .features li+li+li+li,
> #containAbt .features li+li+li+li+li+li, #containAbt .features
> li+li+li+li+li+li+li+li{
>    background-color: #ebdab3;
> }
>
> the first list item gets the lighter color, and ALL OF THE REST get the
> darker shade

That's because e.g. the third list item also matches a selector like 
li+li. It is a li element that follows a li element. Using contextual 
selectors like li:first-child+li you could make the rule apply to even 
items only, but I'd say it really gets more confusing than the use of 
class attributes (even though it would be cleaner in principle to handle 
this purely inside CSS, without "polluting" the markup with class 
attributes that have no logical meaning).


-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
IE7 information -- http://css-discuss.incutio.com/?page=IE7
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread:

Possibly related: