Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,399 Programmers. There are 1,475 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Alternating background color in a column

 
Reply to this topicStart new topic

Alternating background color in a column

katford
post 22 Apr, 2008 - 02:22 PM
Post #1


New D.I.C Head

*
Joined: 22 Apr, 2008
Posts: 1



Hello Everyone,

We currently are working on a sidebar in CSS that features vertically separated headlines. I would like to add visual interest by having the background for each alternating post one particular color (#faebc7). How would I code that?

Thank you so much.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Martyr2
post 22 Apr, 2008 - 03:28 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 3,561

Well in the code that you use to loop through the headlines, you have to setup a flag variable where if the flag is true, print it with one color, then set the flag to false... if the flag is false, print it the other color and set the flag to true.

That way as you go through the loop the flag is going true, false, true, false and printing each headline background with a different color.

If you are not using a programming language to print the headlines, then you will have to just do it manually for each cell you want to change colors or mark each cell with a different CSS class like one called "color1" and another called "color2" and then manually add the class designation to every cell, switching both back and forth.

But if you are printing with a language like PHP, ASP, or ColdFusion the flag approach would be the easiest and fastest.

Hope that makes some sense. smile.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/17/08 06:16AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month