Jump to content
xisto Community
Sign in to follow this  
suicide1405241470

CSS for tables with diferent rows

Recommended Posts

Hi,is there somekind of CSS style i could apply for tables to have diferent colors in diferent lines??? Separated one by one?This way my tables will all have (for example) a red row, a yellow row, a red row, a yellow row, a red row, a yello row, etc...If not, what can i do to achieve this?

Share this post


Link to post
Share on other sites

you can make classes in CSS like this:

.red {        background-color: red;}.yellow {        background-color: yellow;}

and for each row you want red add this to the <td>:

class="red"<td class="red">

for yellow add this:
class="yellow"<td class="yellow">

Share this post


Link to post
Share on other sites

It better to place it in <tr> if you want the whole row to be color with specific color.

<style>.background_red {background-color: red;}.background_yellow {background-color: yellow;}.background_blue {background-color: blue;}</style><table cellspacing="0" cellpadding="3" border="0"><tr class="background_red"><td>Column 1</td><td>Column 2</td><tr><tr class="background_yellow"><td>Column 1</td><td>Column 2</td><tr><tr class="background_blue"><td>Column 1</td><td>Column 2</td><tr></table>

Share this post


Link to post
Share on other sites
tr { background: red; }tr + tr { background: blue; }
Only standard compliant browsers, though. No buggy ones, like IE.

Share this post


Link to post
Share on other sites

tr { background: red; }tr + tr { background: blue; }
Only standard compliant browsers, though. No buggy ones, like IE.

<{POST_SNAPBACK}>


This is probably the most suckiest flaw in IE (at least if you don't take security into account...). With tables that have several columns making every other row different colour makes it highly more readable. But as IE doesn't suppory this and it is like 95% of people in the web using it, you gotta go with clumsy <tr class= .

Geez I hate IE...

Share this post


Link to post
Share on other sites

This is probably the most suckiest flaw in IE (at least if you don't take security into account...). With tables that have several columns making every other row different colour makes it highly more readable. But as IE doesn't suppory this and it is like 95% of people in the web using it, you gotta go with clumsy <tr class= .

Geez I hate IE...

<{POST_SNAPBACK}>


ie 6.0 doesn't support all new property that release on css 2.1, have a 40-60% support to css 2, and 80-90% support to css1, that's why it's buggy. besides ms create its own property of css that only works on ie browser. anyone remember the colored scrollbar :)

Share this post


Link to post
Share on other sites

I know that, but it fixes alot more than bugs.

Only just go and look at what support it offers in IE!

http://dean.edwards.name/IE7/compatibility/

 

No way you can do that with CSS Hacks. This patch is the ultimate solution for MS's crap, which, normal users have to go and clean up again as usual.

Share this post


Link to post
Share on other sites

Hats off to Dead Edwards! That is truly amazing work. I'm most likely going to start using that

 

 

i think that's my last option, coz some ppl disable or hate js and most web users now is migrating to firefox :)

<{POST_SNAPBACK}>


I don't see javascript being disabled a huge problem. Javascript is usually disabled for security reasons. Now if a person is concerned about security he is usually a bit more aware of the technology than the average web user and most likely is not going to use IE.

My rough and in no way statistic relying guess is that less than a per cent of the Internet Explorers that are used in the web have constantly javascript disabled.

Javascript haters are using something else.

 

And besides, asking people to enable javascript to view your site correctly is lot less than to ask them to download, install and switch browser. You can also explain why you require javascript, if for nothing else than to make your users blame it on Microsoft. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.