CSS 的基礎屬性可大致分為字體、文字、顏色背景、邊框、容器、分類與游標等類別。理解這些分類,有助於快速查找與組織樣式。
常見屬性分類
- 字體屬性:font-family、font-style、font-weight、font-size。
- 文字屬性:letter-spacing、text-align、text-indent、line-height。
- 顏色與背景:color、background-color、background-image、background-repeat、background-position。
- 邊框屬性:border-width、border-style、border-color。
- 容器屬性:margin、padding、width、height、float、clear。
- 分類屬性:display、white-space、list-style-type、list-style-image。
- 游標屬性:cursor 可設定 auto、pointer、move、text、wait 等值。
盒模型與布局
CSS 布局的核心是盒模型。每個元素都可視為一個盒子,由內容、內距、邊框與外距組成。常見布局會使用 margin、padding、float、clear、position 與 z-index 來控制位置與層級。
初學時,建議先熟悉這些基礎屬性,再進入 flex、grid 等現代布局。先把盒子計算與層疊概念弄懂,後續學習會更順利。