SHAD Posted February 11, 2010 Share Posted February 11, 2010 Can anyone please tell me how i can make a table so it has different colors on every cell,like the example in the following picture. Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted February 11, 2010 Share Posted February 11, 2010 I use a simple solution but im sure there are different ways echo ' <table cellpadding="1" cellspacing="1" width="75%" border="0"> <tr> <th>Numbers</th> </tr> '; $cblah = 1; while( $cblah <= 10 ) { $colory = ( $cblah % 2 ) ? '#ABABAB' : '#B0B0B0'; echo ' <tr style="background-color: '.$colory.'; color: #000000; font-weight: BOLD;"> <td>'.$cblah.'</td> </tr> '; $cblah++; } echo ' </table> '; Hope this helps (didn't test this). Quote Link to comment Share on other sites More sharing options...
SHAD Posted February 11, 2010 Author Share Posted February 11, 2010 cheers mate :thumbup: Quote Link to comment Share on other sites More sharing options...
Djkanna Posted February 11, 2010 Share Posted February 11, 2010 Look into CSS's :nth-child element :) Unfortunatly there is no support for it within IE (might of known) Which then is fixable using Javascript (Jquery too) But that then leaves the 1% of IE users that are paranoid and have Javascript turned off where it will not work but generally no-one bothers about them so yeah.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.