1、7focus伪类选择器

提示:focus伪类选择器用于焦点元素,焦点就是光标,一般情况下<input>类表单元素

1、语法:

                           input:focus{

                         background-color:yellow;

                                    }

解释:

当我们鼠标点击这个表单,那么它的表单会变色彩,必须是用这个“:focus”这个伪类选择器

自己代码展示:

<!--
 * @Author: error: git config user.name && git config user.email & please set dead value or install git
 * @Date: 2022-05-31 14:46:45
 * @LastEditors: error: git config user.name && git config user.email & please set dead value or install git
 * @LastEditTime: 2022-08-21 19:57:32
 * @FilePath: \code\前端代码\css学习知识\1.1什么是复合选择器\1.7focus伪类选择器.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>获得光标才有颜色、结合表单用“:focus”</title>
    <style>
        input:focus {
            background-color: pink;
            color: red;
        }
    </style>
</head>

<body>

    <input type="text">
    <input type="text">


</body>

</html>

显示结果:


总结

提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了focus伪类选择器用于焦点元素,焦点就是光标,一般情况下<input>类表单元素

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值