使用[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中文网其他相关文章!