使用[attribute ~= "value"]選擇器透過CSS選擇屬性值包含指定單字的元素。
您可以嘗試執行以下程式碼來實作[attribute ~= “值”]選擇器。在這裡,我們搜尋的單字是“Tutorials”,
#Live Demo
<!DOCTYPE html> <html> <head> <style> [alt ~= Tutorials] { border: 5px solid orange; border-radius: 5px; } </style> </head> <body> <img src = "https://www.tutorialspoint.com/videotutorials/images/tutor_connect_home.jpg" height = "200" width = "200" alt = "Tutor Connect"> <img src = "https://www.tutorialspoint.com/videotutorials/images/tutorial_library_home.jpg" height = "200" style="max-width:90%" alt = "Tutorials Library"> </body> </html>
以上是如何用CSS選擇屬性值包含指定單字的元素?的詳細內容。更多資訊請關注PHP中文網其他相關文章!