CSS :nth-of-type(n) 選擇器


使用 CSS :nth-of-type(n) 選擇器為其父元素的第 n 個

元素設定樣式。你可以嘗試執行以下程式碼來實現 :nth-of-type(n) 選擇器

示例

演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         p:nth-of-type(2) {
            background: yellow;
         }
      </style>
   </head>
   <body>
      <p>This is demo text 1.</p>
      <p>This is demo text 2.</p>
      <p>This is demo text 3.</p>
      <p>This is demo text 4.</p>
   </body>
</html>

更新時間:2020年6月30日

148 次瀏覽

開啟你的職業生涯

參加課程並獲得證書

開始
廣告
© . All rights reserved.