下面是一些常用的筛选框:
/* 指定元素 */ p { color: red; } /* 指定类名 */ .my-class { font-weight: bold; } /* 指定ID */ #my-id { text-align: center; } /* 指定属性 */ a[href="https://www.google.com"] { color: blue; } /* 选择子元素 */ div p { font-size: 16px; } /* 选中第一个子元素 */ li:first-child { color: green; } /* 选中倒数第二个子元素 */ li:nth-last-child(2) { color: pink; } /* 选中每个偶数元素 */ li:nth-child(even) { background-color: lightgray; }
以上示例代码只是CSS中一小部分的筛选框,还有更多的选择器可以根据需要进行学习和使用。