css伪类有哪些?

同一个标签,根据其不同的种状态,有不同的样式。这就叫做“伪类”。伪类用冒号来表示。CSS 伪类用于向某些选择器添加特殊的效果。

伪类的语法:

selector : pseudo-class {property: value}

CSS 类也可与伪类搭配使用。

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

伪类连同伪元素一起,他们允许你不仅仅是根据文档 DOM 树中的内容对元素应用样式,而且还允许你根据诸如像导航历史这样的外部因素来应用样式(例如 :visited)。

同样的,可以根据内容的状态(例如在一些表单元素上的 :checked),或者鼠标的位置(例如 :hover 让你知道是否鼠标在一个元素上悬浮)来应用样式。

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()

以上就是css伪类有哪些?的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » CSS3 答疑