css3新增的偽類

2021-09-29 21:25:41 字數 831 閱讀 8877

:root 選擇文件的根元素,等同於 html 元素

:empty 選擇沒有子元素的元素

:target 選取當前活動的目標元素

:not(selector) 選擇除 selector 元素意外的元素

:enabled 選擇可用的表單元素

:disabled 選擇禁用的表單元素

:checked 選擇被選中的表單元素

:after 在元素內部最前新增內容

:before 在元素內部最後新增內容

:nth-child(n) 匹配父元素下指定子元素,在所有子元素中排序第n

:nth-last-child(n) 匹配父元素下指定子元素,在所有子元素中排序第n,從後向前數

:nth-child(odd)

:nth-child(even)

:nth-child(3n+1)

:first-child

:last-child

:only-child

:nth-of-type(n) 匹配父元素下指定子元素,在同類子元素中排序第n

:nth-last-of-type(n) 匹配父元素下指定子元素,在同類子元素中排序第n,從後向前數

:nth-of-type(odd)

:nth-of-type(even)

:nth-of-type(3n+1)

:first-of-type

:last-of-type

:only-of-type

::selection 選擇被使用者選取的元素部分

:first-line 選擇元素中的第一行

:first-letter 選擇元素中的第乙個字元

CSS3 新增偽類

p first of type 父元素中第乙個p子元素 p lastt of type 父元素中最後乙個p子元素 p only of type 父元素中唯一乙個p子元素 p nth of type n 父元素中第n個p型別的p元素 p nth last of type n 父元素中倒數第n個p型別的...

CSS3 新增偽類

p first of type 選擇屬於其父元素的首個 元素的每個 元素。p last of type 選擇屬於其父元素的最後 元素的每個 元素。p only of type 選擇屬於其父元素唯一的 元素的每個 元素。p only child 選擇屬於其父元素的唯一子元素的每個 元素。p nth c...

CSS3新增偽類

p last of type 選擇其父元素的最後的乙個p元素 p last child 選擇其父元素的最後子元素 一定是p才行 p first of type 選擇其父元素的首個p元素 p first child 選擇其父元素的首個p元素 一定是p才行 p only child 選擇其父元素的只有乙...