萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 網頁製作 >> Div CSS 教學

CSS 常用屬性速查手冊:字體、文本、顏色、背景與邊距

字體屬性

屬性說明常用值
font-family字體清單,依序尋找"Microsoft JhengHei", sans-serif
font-style字體風格normal | italic | oblique
font-variant小型大寫字母normal | small-caps
font-weight粗細normal(400) | bold(700) | 100-900
font-size字體大小16px, 1rem, 1.2em, 120%
font綜合簡寫(順序:style variant weight size/line-height family)italic bold 16px/1.5 "Microsoft JhengHei"

文本屬性

屬性說明常用值
text-decoration修飾線none | underline | overline | line-through
text-align水平對齊left | right | center | justify
text-indent首行縮排2em, 24px
letter-spacing字元間距0.1em, 2px(可負值)
word-spacing單詞間距0.2em
white-space空白處理nowrap | pre | pre-wrap
text-transform大小寫轉換uppercase | lowercase | capitalize

顏色屬性

color: #333; / rgb(51,51,51) / hsl(0,0%,20%) — 參考「顏色表示法」五種格式。

背景屬性

屬性說明常用值
background-color背景色同顏色格式
background-image背景圖url(bg.png)
background-repeat平鋪方式repeat | repeat-x | repeat-y | no-repeat
background-attachment固定/捲動scroll | fixed | local
background-position定位center top, 50% 50%, 10px 20px
background綜合簡寫#fff url(bg.png) no-repeat center / cover

邊距屬性

屬性說明簡寫順序
margin外距上 右 下左(順時針)
margin: 10px 20px 30px 40px;
padding內距同上
border邊框border: 1px solid #ccc;(寬 樣式 色)

簡寫規則:1 值=四邊;2 值=上下/左右;3 值=上/左右/下;4 值=上右下左。

copyright © 萬盛學電腦網 all rights reserved