Skip to content
On this page
  • 类选择器是最常用的选择器之一,因为它灵活、可复用。
  • 一个 HTML 元素可以通过 class 属性同时指定多个类名,类名之间用空格分隔,方便组合不同的样式。
  • 写法:.类名 { ... }
css
.box { border: 1px solid #ccc; }
.highlight { background: yellow; }
html
<!-- 同时使用多个类 -->
<div class="box highlight">...</div>