<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>class优先级</title> <style> div{ width:100px; height:100px; margin:20px; } .lik_2{ background:green; } .lik_1{ background:red; } </style> </head> <body> <div class="lik_1 lik_2"></div> <div class="lik_2 lik_1"></div> </body> </html>
样式只与style中的先后顺序有关,而与body中元素的class顺序无关。
时间: 2024-10-14 21:15:46