沐鳴註冊平台_css的偽類有哪些?

同一個標籤,根據其不同的種狀態,有不同的樣式。這就叫做“偽類”。偽類用冒號來表示。css 偽類用於向某些選擇器添加特殊的效果。

css偽類:

:active :any-link :blank :checked :current :default
:defined :dir() :disabled :drop :empty :enabled
:first :first-child :first-of-type :fullscreen :future :focus
:focus-visible :focus-within :has() :host :host() :host-context()
:hover :indeterminate :in-range:invalid :is() :lang() :last-child
:last-of-type :left :link :local-link :not() :nth-child()
:nth-col() :nth-last-child() :nth-last-col() :nth-last-of-type() :nth-of-type() :only-child
:only-of-type :optional :out-of-range :past :placeholder-shown :read-only
:read-write :required :right :root :scope :target
:target-within :user-invalid :valid :visited :where()

偽類的語法:

selector : pseudo-class {property: value}

CSS 類也可與偽類搭配使用。

selector.class : pseudo-class {property: value}

偽類連同偽元素一起,他們允許你不僅僅是根據文檔 DOM 樹中的內容對元素應用樣式,而且還允許你根據諸如像導航歷史這樣的外部因素來應用樣式(例如 :visited)。

同樣的,可以根據內容的狀態(例如在一些表單元素上的 :checked),或者鼠標的位置(例如 :hover 讓你知道是否鼠標在一個元素上懸浮)來應用樣式。

站長推薦

1.雲服務推薦: 國內主流雲服務商,各類雲產品的最新活動,優惠券領取。地址:阿里雲騰訊雲華為雲

2.廣告聯盟: 整理了目前主流的廣告聯盟平台,如果你有流量,可以作為參考選擇適合你的平台點擊進入

鏈接: http://www.fly63.com/article/detial/8393