Blogger Information
Blog 7
fans 0
comment 1
visits 1871
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
这是学习的状态伪类
学,无止尽
Original
220 people have browsed it

状态伪类

根据当前元素的状态来设置

获取焦点时选择时边框变色

  1. .login :focus {
  2. outline: 1px solid red;
  3. border-bottom: none;
  4. }
  • 效果图

所有必填项添加填色

  1. .login :required {
  2. background-color: rgb(241, 19, 11);
  3. }
  • 效果图

复选框选中时将标签文本描红

  1. .login input[type='checkbox']:checked + label {
  2. color: red;
  3. }
  • 效果图

鼠标悬停样式

  1. .login > .submit:hover {
  2. cursor: pointer;
  3. background-color: rgb(53, 170, 158);
  4. color: azure;
  5. }
  • 效果图

当前没有其他属性时可省略

  1. .login :checked + label {
  2. color: rgb(19, 211, 218);
  3. }

基本常用语

结构伪类(与上下文选择器类似)

nth-child()
first-child:
last-child:
nth-last-child()

状态伪类
:hover:鼠标悬停
:enabled:有效控件
:disabled:选中控件
:required:必选控件
:focus:焦点控件
:not():过滤掉某些元素
:empty():空

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post