1、选择器优先级
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="style.css"> <title>Document</title> <style> .a1 {color: red} .a2 { color: yellow} .a3 { color: green;} </style> </head> <body> <div class="a1 a4 a3 a2">hello</div> </body> </html>
// style.css .a4 { color: blue;}
结论是a3起效,这和class先后使用顺序没关,和css样式先后定义顺序有关,a3是最后定义的,会覆盖前面的样式。