【问题标题】:Set border on first table row, w/o using a ID or class在第一行设置边框,不使用 ID 或类
【发布时间】:2011-01-31 10:58:17
【问题描述】:

我正在尝试设计一个我们也没有源代码的网络应用程序。

所以我深入研究了 DOM,但现在所有行都设置了底部边框,我只需要第一行。

#tableID tbody tr td table tbody tr
{
  border-bottom: solid 1px #cccccc; 
}

这可能吗?

【问题讨论】:

    标签: html css html-table css-tables


    【解决方案1】:

    如果你不关心支持 IE6:

    #tableID tbody tr td table tbody:first-child
    {
      border-bottom: solid 1px #cccccc;
    }
    

    【讨论】:

      【解决方案2】:
      #tableID tbody tr td table tbody tr:first-child { }
      

      应该根据 CSS 2 选择器规范选择第一个孩子。

      See here 了解哪些浏览器选择了选择器。

      【讨论】:

      • 需要直接应用到 th/td 没有 tr 所以:#tableID tbody tr td table tbody > tr:first-child td, #tableID tbody tr td table tbody > tr:first-child th { }
      • prodogitalson,是的,做到了!
      猜你喜欢
      • 2019-03-06
      • 2011-12-02
      • 2019-07-06
      • 1970-01-01
      • 1970-01-01
      • 2011-05-19
      • 1970-01-01
      • 2022-06-11
      • 1970-01-01
      相关资源
      最近更新 更多