使用[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" width="200" alt = "Tutorials Library"> </body> </html>
登錄后復制
以上就是如何用CSS選擇屬性值包含指定單詞的元素?的詳細內容,更多請關注www.92cms.cn其它相關文章!