我如何选择仅使用CSS引用的TH的TD



我看到了JavaScript答案,但不仅使用CSS。是否只使用CSS来引用表头的参考表单元格?

如果我有:

    <table id="required-education">
       <thead>
          <tr>
             <th class="tbl-requirement-subheader" colspan=3>
                Basic Skills (General Core) Courses - Area III
             </th>
          </tr>
          <tr>
             <th class="tbl-area-description" colspan=3>
                Social/Behavioral Sciences
             </th>
          </tr>
          <tr>
             <th class="tbl-class-header">Class Name</th>
             <th class="tbl-class-header">Description</th>
             <th class="tbl-class-header">Hours</th>
          </tr>
       </thead>
       <tbody>
          <tr>
             <td> <!-- how do I select these next three td cells only with only CSS? -->
                EMPL 999
             </td>
             <td>Interpersonal Relations and Professional Development</td>
             <td>2</td>
          </tr>
          <tr>
             <td class="tbl-class-decription" colspan=3>a description
    2 credits
             </td>
          </tr>
          <tr>
             <td colspan=3 class="tbl-prerequisite">Prerequisite</td>
          </tr>
          <tr>
             <td class="tbl-prerequisite-info" colspan=3>
                Provisional admission
             </td>
          </tr>
</table>

如果您知道TR的位置,则可以使用子选择器。在您的示例中,您可以使用

tbody tr:first-child td {
  your styles
}

最新更新