用 CSS 選擇 alt 屬性包含單詞“Tutorials”的所有元素


使用 [attribute ~= "value"] 選擇器選擇元素,其屬性值包含使用 CSS 指定的單詞。

您可以嘗試執行以下程式碼來實現 [attribute ~= "value"] 選擇器。此處,我們要搜尋的單詞是“Tutorials”,

示例

即時演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         [alt ~= Tutorials] {
            border: 5px solid orange;
            border-radius: 5px;
         }
      </style>
   </head>
   <body>
      <img src = "https://tutorialspoint.tw/videotutorials/images/tutor_connect_home.jpg" height = "200" width = "200" alt = "Tutor Connect">
      <img src = "https://tutorialspoint.tw/videotutorials/images/tutorial_library_home.jpg" height = "200" width = "200" alt = "Tutorials Library">
   </body>
</html>

更新於: 2020 年 6 月 24 日

245 次瀏覽

開啟您的 職業

完成課程獲得認證

操作指南
廣告
© . All rights reserved.