【问题标题】:How can I add a class name to all the "%th"如何将类名添加到所有“%th”
【发布时间】:2021-07-18 13:05:00
【问题描述】:

我想编辑表格的行内容(添加填充等)。 如果我将类名放在“%tr”中,什么也不会发生。但是当我把它放在“%th”中时,它就起作用了。当然,我不能对每个人都这样做,因为我认为这不是一个好习惯。 那么我该怎么做才能将所有“%th”放在同一个类中而不复制粘贴 15 次呢?

%div{:style => "overflow-x:auto;"}
  %table{:class => "students_table", :border => "1"}
    %thead
      %tr
        %th{:class => "student_table2"} Registration Number
        %th Forename
        %th Surname
        %th Programme Code
        %th Deptcode
        %th Personaltutor
        %th Periodofstudy
        %th Access
        %th Contact
        %th Teaching
        %th Exams
        %th Practicals
        %th Circumstances
        %th Recommendations
        %th Last updated at

【问题讨论】:

  • 欢迎来到 Stack Overflow!为什么不将课程放在tr 上并针对tr.class th { styles } 之类的th - 或者您可以完全在每个th 上放置一个课程,这不一定是坏习惯。

标签: html css sass haml


【解决方案1】:

您可以选择 tr 的直接子级,然后应用您的规则

tr > th {
  color:red;
}

【讨论】:

    猜你喜欢
    • 2011-08-29
    • 2011-09-26
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 2012-06-16
    • 1970-01-01
    • 2013-11-26
    • 2016-06-24
    相关资源
    最近更新 更多