【问题标题】:Alternate mysql table row background colour备用mysql表行背景颜色
【发布时间】:2015-01-27 16:00:12
【问题描述】:

我正在尝试将备用行颜色添加到我的 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; }>";

但这两种方法都不起作用。我怎样才能做到这一点

【问题讨论】:

    标签: mysql


    【解决方案1】:
    th:nth-child(odd) { background-color: #ccc; }
    

    您想让&lt;th&gt; 的背景颜色为浅灰色,而不是&lt;tr&gt;

    【讨论】:

    • 我的错误我只是看看我是否可以更改备用表标题列作为对有效基本思想的测试。但是,当我尝试将 css 应用到表行时 tr:nth-child(odd) { background-color: #ccc; } 它不起作用
    • 我没有正确阅读您的回复。如果我使用 th:nth-child(odd) { background-color: #ccc;它成功地使表头中的备用列交替颜色,但是当我使用 t:nth-child(odd) { background-color: #ccc; } 没有应用样式
    • 我通过删除所有 table td css 并将 css 添加到 table tr 以及一些其他小的 css 调整来解决这个问题
    • 如果你解决了,我认为你应该发布你的解决方案作为答案。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-05
      • 2010-09-26
      • 2020-01-15
      • 1970-01-01
      • 2019-05-30
      • 2014-09-19
      • 2019-08-30
      • 2012-09-29
      相关资源
      最近更新 更多