简体   繁体   中英

How do I select a group of child elements from a parent element of a particular class?

If I have a table as in this example:

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

How do I style the <tr> and <td> elements only if the table is of class="detailView" ?

Use a CSS class selector:

table.detailView tr {
    // your CSS properties
}

table.detailView td {
    // your CSS properties
}

If your table does not have the detailView class no style will be applied.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM