<1 小玩意(覆盖效果)

时间:2021-08-25 05:49:24
 <!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<style>
.show1{ animation:show1 0.25s linear;animation-fill-mode: forwards;}
.show2{ animation:show2 0.25s linear 0.25s;animation-fill-mode: forwards;}
.show3{ animation:show3 0.25s linear;animation-fill-mode: forwards;}
.show4{ animation:show4 0.25s linear 0.25s;animation-fill-mode: forwards;}
@keyframes show1{
0%{ width:0; height:2px; background-color:red}
100%{ width:150px; height:2px; background-color:red}
}
@keyframes show2{
0%{ width:2px; height:0; background-color:red}
100%{ width:2px; height:148px; background-color:red}
}
@keyframes show3{
0%{ width:2px; height:0; background-color:red}
100%{ width:2px; height:148px; background-color:red}
}
@keyframes show4{
0%{ width:0; height:2px; background-color:red}
100%{ width:148px; height:2px; background-color:red}
}
</style>
<script src="jquery.js"></script>
</head>
<body>
<div style=" background-color:#CCC; width:150px; height:150px; margin:200px 0 0 200px; position:relative" id="f">
<div id="child1"></div>
<div id="child2" style=" position:absolute;left:148px;"></div>
<div id="child3"></div>
<div id="child4" style=" position:absolute;top:148px"></div>
</div>
</body>
<script>
$("#f").mouseover(function(){
$("#child1").addClass("show1");
$("#child2").addClass("show2");
$("#child3").addClass("show3");
$("#child4").addClass("show4");
})
$("#f").mouseout(function(){
$("#child1").removeClass("show1");
$("#child2").removeClass("show2");
$("#child3").removeClass("show3");
$("#child4").removeClass("show4");
})
</script>
</html>