首页 > 解决方案 > 如何将类名添加到所有“%th”

问题描述

我想编辑表格的行内容(添加填充等)。如果我将类名放在“%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

标签: htmlcsssasshaml

解决方案


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

tr > th {
  color:red;
}

推荐阅读