css实现一个西洋镜跑马灯旋转动画效果代码
代码语言:html
所属分类:动画
代码描述:css实现一个西洋镜跑马灯旋转动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
:root {
--zoetrope-radius: 50vmin;
--gap-ratio: 0;
--effective-frame-width: calc(
(var(--zoetrope-radius) * 2 * 3.14159 / 11) * (1 - var(--gap-ratio))
);
--frame-width: var(--effective-frame-width);
--frame-height: var(--frame-width);
--zoetrope-radius-inverse: calc(-1 * var(--zoetrope-radius));
--zoetrope-radius-outer: calc(var(--zoetrope-radius) + 3vmin);
--zoetrope-tilt: -16deg;
--zoetrope-depth: -100vmin;
--spin-duration: 600ms;
}
*,
::after,
::before {
border-style: solid;
border-width: 0;
box-sizing: border-box;
}
body {
background: radial-gradient(
circle,
#d4c4a8 0,
#b49b78 50%,
#8b7353 85%,
#5c4b3a 100%
),
radial-gradient(circle at 30% 20%, rgba(0, 0, 0, 0.15) 0, transparent 80%),
radial-gradient(circle at 70% 80%, rgba(0, 0, 0, 0.1) 0, transparent 90%);
background-color: #c8a88a;
color: #3a3023;
font-family: "Roboto", sans-serif;
height: 100vh;
line-height: 1.5;
margin: 0;
overflow: hidden;
width: 100%;
}
.wrapper {
align-items: center;
display: grid;
justify-items: center;
place-items: center;
}
.zoetrope {
perspective: 1000px;
}
.zoetrope,
.zoetrope-wrapper {
height: calc(var(--zoetrope-radius) * 2);
position: relative;
width: calc(var(--zoetrope-radius) * 2);
}
.zoetrope-wrapper {
align-items: center;
animation: spin var(--spin-duration) linear infinite;
display: grid;
justify-items: center;
place-items: center;
transform: translateZ(var(--zoetrope-depth)) rotateX(var(--zoetrope-tilt));
transform-style: preserve-3d;
}
.frame {
backface-visibility: hidden;
background: url(//repo.bfw.wiki/bfwrepo/images/xiyangjing/the-horse-in-motion-reverse.png);
background-position: calc(var(--index) * -100% / 11) 0;
background-size: cover;
height: var(--frame-height);
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%) rotateY(var(--ry))
translateZ(var(--zoetrope-radius-inverse));
width: var(--frame-width);
}
@keyframes spin {
from {
transfor.........完整代码请登录后点击上方下载按钮下载查看
网友评论0