网页刚进去有一个大图片用鼠标点一下大图片向上下分开,或者消失,这种效果可以做出来吗不用js,
把大图片分成上下两个图片,在js中设置鼠标点击事件用css动画让两个图片向上下分开
不用js的
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> 页面名称 </title>
</head>
<style type="text/css">
html,body {
padding: 0;
margin: 0;
height: 100%;
}
@keyframes anim1{
0% {transform: translatey(0%);}
100% {transform: translatey(-100%);}
}
@keyframes anim2{
0% {transform: translatey(0%);}
100% {transform: translatey(100%);}
}
#label {
position: absolute;
top: 0;
left: 0;
z-index: 999;
width: 100%;
height: 100%;
}
#imgbox {
width: 100%;
height: 100%;
overflow: hidden;
}
#upimg {
width: 100%;
height: 50%;
background: #099 url("a.jpg") no-repeat top;
background-size: 100vw 100vh;
}
#dnimg {
width: 100%;
height: 50%;
background: #099 url("a.jpg") no-repeat bottom;
background-size: 100vw 100vh;
}
#che {
display: none;
}
#che:checked + div #upimg {
animation: anim1 5s forwards;
}
#che:checked + div #dnimg {
animation: anim2 5s forwards;
}
#che:checked + div + label {
display: none;
}
</style>
<body>
<input type="checkbox" id="che" />
<div id="imgbox">
<div id="upimg"></div>
<div id="dnimg"></div>
</div>
<label for="che" id="label">
</label>
</body>
</html>
如有帮助,望采纳!谢谢!