Solved

css alternate bgcolor li

Posted on 2007-03-28
2
326 Views
Last Modified: 2012-08-13
Hi all at EE,

I have a wysiwyg editor in a database backend that allows updating of text for the front end of my website.
My question is, is it possible for css, on the front end,  to automatically change the background color of any li to a certain color, and then have the next li another.. and repeat..
So in a sense alternating bgcolor for each li inside of a ul. I know how to do this in php for example but wondering if possible with css from what a user has entered into the database field which is displayed.

Can someone help me with this?
Thanks
Pauliostro
0
Comment
Question by:Pauliostro
2 Comments
 
LVL 30

Accepted Solution

by:
VirusMinus earned 500 total points
ID: 18806301
no, with plain CSS you cannot determine alternate elements in a html document.

you will either need to mark the alternating elements with a class when / before saving into the database

OR

using a javascript, when the document loads, traverse the DOM and pick out the alternate lists and alter their style attributes.
0
 

Author Comment

by:Pauliostro
ID: 18806638
Thanks, i'll research your options.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now