一、焦点伪类
属性:input:focus {}
input标签获取光标焦点的状态
效果展示:
没有修改的效果
加属性后鼠标放上去的效果
书写代码:
<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>Document</title>
<style>
input:focus {
background-color: #ccc;
color: rgb(240, 168, 61);
}
</style>
</head>
<body>
<input type="text">
</body>
二、属性选择器
通过标签的属性值来选择标签
效果展示:
标签基础效果:
标签加了属性后的效果
书写代码:
<!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>Document</title>
<style>
input[type] {
width: 100px;
height: 50px;
}
input[type=text] {
background-color: #ccc;
}
input[type=password] {
background-color: pink;
}
</style>
</head>
<body>
<input type="text">
<input type="password" name="" id="">
</body>
</html>