【问题标题】:draw html table header绘制html表头
【发布时间】:2017-12-02 22:48:45
【问题描述】:

我有这样的表结构

 <table class="dgrid" rules="all" id="Gridview2" style="border-collapse: collapse;" cellspacing="0" border="1">
    <tbody>
        <tr>
            <th scope="col">HEADER 1</th>
            <th scope="col">HEADER 2</th>
            <th scope="col">HEADER 3</th>
            <th scope="col">HEADER 4</th>
        </tr>
        <tr>
            <td>DATA 1</td>
            <td>DATA 2</td>
            <td>DATA 3</td>
            <td>DATA 4</td>
        </tr>
    </tbody>
</table>

基于这种结构,我想用颜色绘制标题表。我做了这个 CSS 但什么也没发生

<style>
    .dgrid th scope {
        color: #18bc9c;
    }
</style>

【问题讨论】:

    标签: asp.net html css html-table


    【解决方案1】:

    你需要使用属性选择器[attribute="value"]

    .dgrid th[scope="col"] {
      color: #18bc9c;
    }
    <table class="dgrid" rules="all" id="Gridview2" style="border-collapse: collapse;" cellspacing="0" border="1">
      <tbody>
        <tr>
          <th scope="col">HEADER 1</th>
          <th scope="col">HEADER 2</th>
          <th scope="col">HEADER 3</th>
          <th scope="col">HEADER 4</th>
        </tr>
        <tr>
          <td>DATA 1</td>
          <td>DATA 2</td>
          <td>DATA 3</td>
          <td>DATA 4</td>
        </tr>
      </tbody>
    </table>

    【讨论】:

    • 哦,谢谢,它现在可以工作了.. 我认为 CSS3 没有选择器。谢谢老兄!
    猜你喜欢
    • 2020-03-07
    • 2011-09-28
    • 2018-04-12
    • 2018-06-26
    • 2013-05-10
    • 1970-01-01
    • 1970-01-01
    • 2013-10-01
    • 2014-09-23
    相关资源
    最近更新 更多