css不常用的4个选择器-个人向
①:element1.element2 (给同时满足有 element1 和 element2 2 个类名的元素添加样式) <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <style> .test1.test2 { color: red; } </style> </head> <body> <div class="test1">123</div> <div class="test1 test2"> 123 </div> </body> </html> ②:[attribute^=value] (匹配属性值以指定值开头的每个元素,如下面demo,给属性为 href 且值以 http 开头的所有 a 元素添加样式) <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <style> a { display: block; border-bottom: 1px solid #ccc; } [href^=http]::after { content: 'after伪元素'; display: inline-block; margin: 20px; width: 50px; height: