css中的伪类有哪些

青灯夜游
发布: 2021-07-22 16:18:02
原创
9714人浏览过
css伪类:“:active”、“:any-link”、“:blank”、“:checked”、“:current”、“:first”、“:first-child”、“:future”、“:focus”、“:has()”、“:host”等。

css中的伪类有哪些

本教程操作环境: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、动态伪类选择器

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

  • E:link

  • E:visited

  • E:active

  • E:hover

  • E:focus

2、目标伪类选择器

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

E:target

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

3、语言伪类选择器

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

E:lang(language)

4、元素状态伪类选择器

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

  • E:checked

eg:

input[type="checkbox"]:checked{}
登录后复制
  • E:enabled

eg:

input[type="text"]:checked{}
登录后复制
  • E:disabled

eg:

input[type="text"]:disabled{}
登录后复制

5、结构伪类选择器

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

  • :nth-child

  • :nth-last-child

  • :nth-of-type

  • :nth-last-of-type

  • :first-child

  • :last-child

  • :only-child

  • :first-of-type

  • :last-of-type

  • :only-of-type

  • :root 匹配元素所有在文档的根元素

  • :empty 选择没有子元素的元素,且不包含节点

6、否定伪类选择器

  • E:not(F) 匹配所有除F外的E元素

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

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

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
相关标签:
css
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号