效果图
代码
一,html部分
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/zzh.css"/>
<script type="text/javascript" src="js/zzh.js">
</script>
</head>
<body>
<div class="bkg">
<div class="login" id="login1">
<form class="input_box">
<ol>
<li>
<label style="float: left;">用户名</label>
<input type="text" name="" id="" value="" />
</li>
<li>
<label style="float: left;">密码</label>
<input type="password" name="" id="" value=""/>
</li>
<li>
<button type="submit" class="button">登陆</button>
</li>
</ol>
</form>
</div>
<img class="person" src="img/person.png" id="person1" />
<img class="log" src="img/log.png" id="log1" />
<img class="bottom" src="img/bottom1.png" id="bottom1"/>
</div>
</body>
</html>
二,css部分
*{
margin: 0;
padding: 0;
}
.bkg{
position: relative;
width: 100%;
height: 975px;
background-image:url(../img/bkg.jpg);
background-repeat: no-repeat;
background-size: cover;
}
.login{
position: absolute;
margin: 30px auto;
width: 400px;
height: 300px;
background: rgb(192,192,192,0.3);
left: 0;
top: 0;
right: 0;
bottom: 0;
border-radius: 6%;
transition: 0.8s;
}
.login:hover{
width: 430px;
}
.person{
position: absolute;
top: 120px;
left: -700px;
transition: 1.2s ease-out;
}
.log{
float: right;
}
.input_box{
position: relative;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: 20px auto;
width: 300px;
height: 200px;
background: rgb(192,192,192,0.1);
text-align: center;
border-radius: 4%;
font-size: 20px;
}
.input_box ol li{
display: inline-block;
margin-top: 20px;
list-style: none;
}
.input_box ol li label{
float: left;
width: 80px;
height: 30px;
line-height: 1em;
}
.input_box ol li input{
float: left;
width: 180px;
height: 30px;
text-align: left;
line-height: 100%;
padding: 1px 9px;
}
.button{
margin: 0;
padding: 0;
border: 2px solid rgb(192,192,192,0.7);
width: 90px;
height: 30px;
background: rgb(192,192,192,0.5);
font-family: serif;
font-size: 20px;
letter-spacing: 6px;
transition: 0.5s;
}
.button:hover{
transform: scale(1.1,1.1);
}
.bottom{
position: absolute;
width: 100%;
height: 0px;
background-image:url(../img/bottom1.png);
background-repeat: no-repeat;
background-size: cover;
top: 925px;
transition: 0.8s ease-out;
}
三,js部分
window.onload = function(){
var login = document.getElementById("login1");
var person = document.getElementById("person1");
var bottom = document.getElementById("bottom1");
login.onmouseover = function(){
person.style.left = 0;
bottom.style.height = "50px";
}
login.onmouseout = function(){
person.style.left = "-700px";
bottom.style.height = 0;
}
}
注:如果要复制运行这个代码,需要注意一些图片资源的路径
图片素材
bkg.jpg
bottom1.png
log.png
person.png
本人ps技术有限,图可能扣的不大好,下面的是原图,有大佬可以自己扣
css动画实现表白爱心树落叶效果
css3动画特效之字节跳动