html - CSS Odd/Even td nested -
html - CSS Odd/Even td nested -
i trying come style rows odd/even styles. row going marked class odd/even style needs apply containing td/th.
the reason style can't placed straight on row because applying background colors row instead of td/th causes inconsistent results in browsers.
when apply color td/th causes problem in nested scenarios.
<html><head><title>nesting</title></head><body> <style type="text/css"> .even td, .even th { background-color: #fbfcfd; } .odd td, .odd th { background-color: #feffff; } </style> <table width="100%"> <tr class="even"> <th>test</th> <td>test</td> </tr> <tr class="odd"> <th>test</th> <td>test</td> </tr> <tr class="even"> <th>test</th> <td>test</td> </tr> <tr class="odd"> <th>test</th> <td> <table width="100%"> <tr class="even"> <th>test</th> <td>test</td> </tr> <tr class="odd"> <th>test</th> <td>test</td> </tr> <tr class="even"> <th>test</th> <td>test</td> </tr> <tr class="odd"> <th>test</th> <td> <table width="100%"> <tr class="even"> <th>test</th> <td>test</td> </tr> <tr class="odd"> <th>test</th> <td>test</td> </tr> <tr class="even"> <th>test</th> <td>test</td> </tr> <tr class="odd"> <th>test</th> <td>test</td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body></html>
what ideal if following, unfortunately work in older browsers.
<style type="text/css"> .even > td, .even > th { background-color: #fbfcfd; } .odd > td, .odd > th { background-color: #feffff; } </style>
see problem live - http://jsfiddle.net/fb9db/
how switching evens , odds in css?
http://jsfiddle.net/fb9db/1/
<style type="text/css"> .even td, .even th { background-color: #fbfcfd; } .odd td, .odd th { background-color: #feffff; } </style>
another thing utilize reddish color cover entire tabular box's background , assign background color odds..
html css background-color
Comments
Post a Comment