Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

css alternate bgcolor li

Posted on 2007-03-28
2
328 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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 learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

860 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