【问题标题】:How do I select a group of child elements from a parent element of a particular class?如何从特定类的父元素中选择一组子元素?
【发布时间】:2017-01-19 06:12:26
【问题描述】:

如果我有这个例子中的表格:

<table class="detailView">
   <tr>
      <td>Value1</td>
      <td>value2</td>
   </tr>
</table>

如何设置&lt;tr&gt;&lt;td&gt; 元素的样式仅当表格属于 class="detailView" 时?

【问题讨论】:

    标签: html css css-selectors html-table


    【解决方案1】:

    使用 CSS 类选择器:

    table.detailView tr {
        // your CSS properties
    }
    
    table.detailView td {
        // your CSS properties
    }
    

    如果您的表格没有 detailView 类,则不会应用任何样式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多