0048 :focus -- 获得焦点元素

:focus 伪类 选择器:用于选取获得焦点的元素 。 我们这里主要针对的是 表单元素。

:hover

语法:

.total input {
  border: 1px solid #ccc;
  height: 30px;
  width: 40px;
  transition: all .5s;
}
/*这个input 获得了焦点*/
.total input:focus {
  width: 80px;
  border: 1px solid skyblue;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    input {
        outline: none;
    }
    input:focus {
        background-color: pink;
        border: 1px solid red;
        height: 50px;
    }
    </style>
</head>
<body>
    <input type="text">
</body>
</html>
.page_skip input {
    width: 46px;
    height: 36px;
    border: 1px solid #ccc;
    text-align: center;
    /*过渡写在本身上 谁做动画,给谁加*/
    transition: all 0.3s;
}
/*表单获得焦点后 */
.page_skip input:focus {
    width: 88px;
    border: 1px solid skyblue;
}

猜你喜欢

转载自www.cnblogs.com/jianjie/p/12127069.html