1. 清除input获取焦点时默认的边框 outline-style: none;
<!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 {
width: 200px;
height: 50px;
border: 2px solid green;
/* 去除focus聚焦外边框 */
outline-style: none;
}
</style>
</head>
<body>
<input type="text">
</body>
</html>
2 . 设置你想要的input获取焦点时的边框
input:focus { outline: 2px solid pink; border: 0;}
<!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 {
width: 200px;
height: 50px;
border: 2px solid green;
}
input:focus {
outline: 2px solid pink;
border: 0;
}
</style>
</head>
<body>
<input type="text">
</body>
</html>