一 css的引入方式
1.行內(nèi)樣式:在標(biāo)簽的style屬性中設(shè)定css樣式。
<div style="width:100px;height:100px;background-color:red;"></div>
2.內(nèi)嵌式: 是將css樣式集中寫在網(wǎng)頁中的head標(biāo)簽內(nèi)的style中。
<style>
div{
width:100px;
height:100px;
}
</style>
3.鏈接式:引入外部css文件,在head標(biāo)簽中使用link標(biāo)簽引入外部樣式表文件。
<link type="text/css" rel="stylesheet" href="style.css"/>
4.導(dǎo)入樣式:
<style>
@importurl(style.css);
</style>
二 css選擇器
1.標(biāo)簽選擇器
2.類選擇器
3.ID選擇器
4.通用選擇器
5.偽類選擇器
6.后代選擇器
7.子元素選擇器
8.群組選擇器
9.相鄰選擇器
10.交集選擇器
11.表單類型選擇器
三 css長度單位
1.相對長度單位: px em
2.絕對長度單位: mm cm
四 字體屬性
字體 font-family:"黑體"
粗細(xì) font-weight:100-900 bold bolder lighter
英文字母大小寫轉(zhuǎn)換: text-transform: capitalize(首字母大寫)
uppercase(全大寫)
lowercase(全小寫)
文字大小:font-size:px/em/rem/%;
文字裝飾效果: text-decoration: underline(下劃線)
line-through(刪除,中間線)
overline(上劃線- -)
none
blink(文字閃爍 不推薦使用)
段落首行縮進(jìn):text-indent: px/em;
設(shè)置字詞間距:letter-spacing: px ; 中文、字母,字間距
word-spacing:px; 只用于英文,單詞與單詞的間距
文本的水平位置:text-align: left/right/center/justify/
文字顏色:color
段落的垂直對齊方式:vertical-align
行高:line-height:px/%
五 背景屬性 background
背景圖片 background-image:url(路徑)
背景圖片平鋪:background-repeat:repeat(默認(rèn)平鋪)/repeat-x(水平平鋪)/repeat-y(垂直
平鋪)/no-repeat(不平鋪)
背景圖片定位: background-position: 水平(left/right/center) 垂直(top/bottom/center);
背景位置固定:background-attachment:fixed(固定定位)/scroll
background復(fù)合屬性:
background:url(路徑) no-repeat right bottom fixed 多個屬性之間用空格隔開
背景圖片大?。篵ackground-size:px/% px/%; 空格隔開,不能用在復(fù)合屬性中。