使用[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选择属性值包含指定单词的元素?的详细内容。