所属分类:web前端开发
使用[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://img.zzsucai.com/202309/23/cLfuh837786122517.jpg" height = "200" width = "200" alt = "Tutor Connect"> <img src = "https://img.zzsucai.com/202309/23/u7UxI161161122530.jpg" height = "200" width="200" alt = "Tutorials Library"> </body> </html>