DOM的思維方去定義CSS

來源:互聯網
上載者:User

其實在看這篇資料以前 我也有過這樣的思維
"文檔物件路徑圖"大家都很熟悉吧
我把這樣的思維方式運用到css定義上
舉個例子:
有這麼個表格
<table id="table">
<tbody>
<tr class="tr1">
<td class="td1">1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
我想控制table裡的tr樣式
<style>
#table tbody tr {
.......................................
}
</style>
控制table裡的td樣式
<style>
#table tbody tr td {
.......................................
}
</style>
控制某個tr裡的td
<style>
#table tbody tr.tr1 td {
.......................................
}
</style>
控制某個tr裡的某個td
<style>
#table tbody tr.tr1 td.td1 {
.......................................
}
</style>
是不是有一級一級下來的感覺
個人感覺這樣寫很規範
如果覺得我的思維輻射得不確切 勿怪

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.