代码示例:
/* 错误示例: */ .my-class { color: red; }
@media screen and (max-width: 768px) { .my-class { font-size: 16px; } }
.my-other-class { background-color: black; }
/* 正确示例: */ .my-class { color: red; }
.my-other-class { background-color: black; }
@media screen and (max-width: 768px) { .my-class { font-size: 16px; } }
/* 解析:在正确示例中,按照选择器的优先顺序对样式进行了分组。 首先是.my-class的样式,其次是.my-other-class的样式, 最后是针对媒体查询@media screen and (max-width: 768px)的样式。 */