CSS 参考手册
CSS3 [attribute^=value] 选择器
设置class属性值以"test"开头的所有div元素的背景颜色
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <style> div[class^="test"] { background: #ffff00; } </style> </head> <body> <div class="first_test">The first div element.</div> <div class="second">The second div element.</div> <div class="test">The third div element.</div> <p class="test">This is some text in a paragraph.</p> </body> </html>
运行结果:
点击运行 »