• 技术文章 >web前端 >前端问答

    css中的伪类有哪些

    青灯夜游青灯夜游2021-07-22 16:18:02原创608

    css伪类:“:active”、“:any-link”、“:blank”、“:checked”、“:current”、“:first”、“:first-child”、“:future”、“:focus”、“:has()”、“:host”等。

    本教程操作环境:windows7系统、CSS3版、Dell G3电脑。

    伪类选择器(简称:伪类)通过冒号来定义,它定义了元素的状态,如点击按下,点击完成等,通过伪类可以为元素的状态修改样式。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()

    常用的伪类及其分类

    1、动态伪类选择器

    不同的状态,使用不同的样式。

    2、目标伪类选择器

    用来匹配页面的URI中某个标识符的目标元素。

    E:target

    选择匹配E的所有元素,且匹配元素被相关URL指向。

    3、语言伪类选择器

    用来匹配使用指定语言的元素。

    E:lang(language)

    4、元素状态伪类选择器

    当元素处于某种状态下时,才起作用,在默认状态下不起作用。

    eg:

    input[type="checkbox"]:checked{}

    eg:

    input[type="text"]:checked{}

    eg:

    input[type="text"]:disabled{}

    5、结构伪类选择器

    这个就比较多了,平时用的也比较频繁。

    6、否定伪类选择器

    (学习视频分享:css视频教程

    以上就是css中的伪类有哪些的详细内容,更多请关注php中文网其它相关文章!

    声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
    专题推荐:css 伪类
    上一篇:css样式文件该放到哪 下一篇:css不继承父类的属性有哪些
    大前端线上培训班

    相关文章推荐

    • css3ps如何安装• asp怎样引入css样式• 怎么加载css文件• JavaScript怎么给CSS加样式• css怎么实现心形• css怎么实现两列布局

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网