CSS 命名規(guī)則:
只能使用字母物舒,數(shù)字,下劃線(_)戏锹,連字符(-)
Id 的作用
可以作為錨點(diǎn)冠胯, 當(dāng)訪問(wèn)url的時(shí)候,可以在后面加上#景用, 網(wǎng)頁(yè)會(huì)直接定位到該標(biāo)簽
<div id="R">test</div>
訪問(wèn)的url : index.html#R
就可以直接定位到這個(gè)元素
name屬性也有這個(gè)作用
<a name="R">test</a>
也可以實(shí)現(xiàn)相同的功能
Paste_Image.png
Paste_Image.png
偽類:
- :link
- :hover
- :visited
- :active
- :foucs
- :not()
img:not(.port)
a[href^='http://']:not([href*="google.com"])
- 用否定選擇器只能使用簡(jiǎn)單的選擇器(元素選擇器涵叮, 通用選擇器,類選擇器伞插,ID選擇器或者偽類)
- 不能使用派生選擇器,偽類元素群組選擇器或其組合
- 不能使用多個(gè)否定選擇器
偽元素
- :first-line
- :first-letter
- :before
- :after
- ::selection . (只能設(shè)置color 和backgorund-color盾碗,必須雙冒號(hào))
- :frist-child
- :last-child
- :nth-child
tr:nth-child(odd)
tr:nth-child(even)
tr:nth-child(3n+2)
- :first-of-type
- :last-of-type
- :nth-of-type
屬性選擇器
- 屬性等于某個(gè)值
- 屬性以xxx開(kāi)頭 ^=
- 屬性以xxx結(jié)尾 $=
- 屬性包含xxx 媚污。 *=
input[type="text"]
a[href^="http://"]
a[href$=".pdf"]
img[src*="headshot"]