Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Table alternating row colors not working

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #197721
    Beauford
    Participant

    Hi, I have a table I am getting from a mysql database using php and I want to have odd and even rows a different color. I am using a style sheet and trying to implement the css code for this with no luck. Am I overwriting something with other code or not using it properly, any help is appreciated.

    Thanks

    I also want to highlight a row on mouse over but haven’t even got to look at that yet.

    Here is the css code for table. In my HTML I am using <Table id=”customer”>

    table.center {
    margin-left:auto;
    margin-right:auto;
    }
    #customers
    {
    font-family: Helvetica, sans-serif;
    width:850px;
    text-align: left;
    margin: auto;
    border-collapse: collapse;
    }
    #customers td
    {
    font-size: .9em;
    height:20px;
    border-left: 1px solid #DDDDDD;
    border-right: 1px solid #DDDDDD;
    padding: 1px 1px 1px 2px;
    }
    #customers th
    {
    font-size: .9em;
    height:20px;
    border: 1px solid #DDDDDD;
    padding: 1px 1px 1px 2px;
    background: url(http://local.me/images/fhbg.gif) repeat;
    }
    #customers tr.alt td
    {
    color:#000000;
    background-color:#EAF2D3;
    }
    #customers td
    {
    font-size: .9em;
    background-color:#ffffff;
    }
    #customers tr:nth-child(even) { /(even) or (2n 0)/
    background: #A4D1FF;
    }
    #customers tr:nth-child(odd) { /(odd) or (2n 1)/
    background: #EAF4FF;
    }

    #197723
    Senff
    Participant

    You’re giving the rows different, alternating colors, but the cells within the rows are still white (which will override the row color).

    So, remove the background color on the TD.

    And remove the /(odd) or (2n 1)/ as this is not the proper way of adding comments.

    #197733
    Beauford
    Participant

    Right, I see that now. I figured I was over riding somewhere I just wasn’t seeing it. Thanks

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.