效果展示

HTML
<!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>用户登录</title>
<link rel="stylesheet" href="../CSS/1.CSS">
<script src="../JS/jQurey3.6.0.JS"></script>
</head>
<body>
<div class="container">
<h1>用户登录</h1>
<form action="">
<input type="text" class="tbx" placeholder="账号">
<input type="password" class="tbx" placeholder="密码">
<input type="submit" class="sub" value="登录">
</form>
</div>
<script>
var con = document.querySelector('.container');
let isIn = true;
let isOut = false;
var span;
con.addEventListener('mouseenter',(e)=>{
if(isIn){
let inX = e.clientX-e.target.offsetLeft;
let inY = e.clientY-e.target.offsetTop;
let el = document.createElement('span');
el.style.left = inX+'px';
el.style.top = inY+'px';
con.appendChild(el);
$('.container span').removeClass('out');
$('.container span').addClass("in");
span = document.querySelector('.container span');
isIn = false;
isOut = true;
}
})
con.addEventListener('mouseleave',(e)=>{
if(isOut){
let outX = e.clientX-e.target.offsetLeft;
let outY = e.clientY-e.target.offsetTop;
$('.container span').removeClass('in');
$('.container span').addClass('out');
$('.out').css('left',outX+'px');
$('.out').css('top',outY+'px');
isOut = false;
setTimeout(() =>{
con.removeChild(span);
isIn = true;
},500)
}
})
</script>
</body>
</html>
css
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgb(253, 253, 253);
}
.container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
width: 400px;
height: 500px;
border-radius: 20px;
background-color: #4471a3;
box-shadow: 15px 15px 10px rgba(33,45,58,.3);
overflow: hidden;
position: relative;
}
.container form {
width: 400px;
height: 250px;
display: flex;
justify-content: space-around;
flex-direction: column;
align-items: center;
z-index: 1;
}
.container form .tbx {
width: 250px;
height: 40px;
outline: none;
border: none;
color: rgb(113, 113, 113);
font-size: 15px;
}
.container form .tbx::placeholder {
color: rgb(193, 190, 190);
font-size: 16px;
}
.container form .sub {
width: 250px;
height: 40px;
outline: none;
border: 1px solid #fff;
border-radius: 20px;
letter-spacing: 5px;
color: #fff;
background: none;
cursor: pointer;
margin-top: 20px;
}
.container h1 {
color: #fff;
font-size: 45px;
letter-spacing: 5px;
font-weight: normal;
text-shadow: 5px 5px 5px rgba(33,45,58,.4);
z-index: 1;
}
.container .in {
position: absolute;
top: 0;
left: 0;
display: block;
width: 0;
height: 0;
border-radius: 50%;
background: rgb(242, 73, 73);
transform: translate(-50%,-50%);
animation: in 0.5s ease-out forwards;
}
.container .out {
position: absolute;
top: 0;
left: 0;
display: block;
width: 1200px;
height: 1200px;
border-radius: 50%;
background: rgb(242, 73, 73);
transform: translate(-50%,-50%);
animation: out 0.5s ease-out forwards;
}
@keyframes in {
0% {
width: 0;
height: 0;
}
100% {
width: 1200px;
height: 1200px;
}
}
@keyframes out {
0% {
width: 1200px;
height: 1200px;
}
100% {
width: 0;
height: 0;
}
}