备用mysql表行背景颜色

时间:2014-11-29 01:47:24

标签: mysql

我正在尝试将替代行颜色添加到我的mysql表中。我正在使用此代码来回显表结构

//creating our table    
    echo "<tr>";
        echo "<th>ID</h3></th>";
        echo "<th>First Name</th>";
        echo "<th>Last Name</th>";
        echo "<th>email</th>";
        echo "<th>street</th>";
        echo "<th>Suburb</th>";
        echo "<th>State</th>";
        echo "<th>Action</th>";
    echo "</tr>";

到目前为止,我已经尝试了

//creating our table    
    echo "<tr:nth-child(odd) { background-color: #ccc; }>";

并将其添加到外部样式表

table tr:nth-child(odd) { background-color: #ccc; }>";

但这两种方法都不奏效。我怎么能实现这个

2 个答案:

答案 0 :(得分:0)

th:nth-child(odd) { background-color: #ccc; }

您希望<th>的背景颜色为浅灰色,而不是<tr>

答案 1 :(得分:0)

在che-azeh的建议中,我将我的评论重新发布作为答案我通过删除所有表格td css并将css添加到表格tr以及其他一些小的CSS调整来解决这个问题