代码运行网站:
https://www.runoob.com/try/try.php?filename=tryhtml5_video_bear
全部代码
<!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>
.father{
width: 200px;
height: 280px;
position: relative;
}
.father:hover p{
animation: p_change 0.5s forwards;
}
a{
width: 100%;
height: 100%;
background-color: red;
display: inline-block;
}
p{
margin: 0px;
width: 10%;
height: 10%;
background-color: aqua;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
transition: all 0.5s;
}
@keyframes p_change {
100%{
width: 100%;
height: 100%;
opacity: 1;
}
}
</style>
</head>
<body>
<div class="father">
<a>
</a>
<p></p>
</div>
</body>
</html>