逛某乎无意间发现了一个广告的过渡动画挺有意思,实现一下。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.container {
position: relative;
width: 300px;
height: 300px;
overflow: hidden;
}
.transition-img {
width: 300px;
height: 300px;
background-repeat: no-repeat;
overflow: hidden;
}
.transition-img1 {
background-image: url(./img/purple.png);
z-index: 99;
}
.transition-img2 {
position: absolute;
top: 0;
left: 0;
background-image: url(./img/orange.png);
z-index: 100;
width: 1200px;
height: 1200px;
border-radius: 86% 0 0 0;
animation: ImgTransitionAniamtion 7s ease forwards;
}
@keyframes ImgTransitionAniamtion {
0% {
border-radius: 86% 0 0 0;
}
50% {
border-radius: 0% 0 0 0;
}
100% {
border-radius: 86% 0 0 0;
}
}
</style>
</head>
<body>
<div id="app">
<div class="container">
<div class="transition-img transition-img1"></div>
<div class="transition-img transition-img2"></div>
</div>
</div>
</body>
</html>