div+css实现立体金刚石旋转动画效果代码
代码语言:html
所属分类:动画
代码描述:div+css实现立体金刚石旋转动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
@property --scale {
syntax: '<integer>';
inherits: false;
initial-value: 1;
}
@property --border {
syntax: '<color>';
inherits: false;
initial-value: #ffffff90;
}
:root {
--scale: 1;
--border: #ffffff90;
}
* {
transform-style: preserve-3d;
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
perspective: 1000vmin;
background: radial-gradient(circle at 50% 150%, #3b8dff, #021320 70%, #000);
cursor: zoom-in;
transition: --scale 0.5s ease 0s;
}
body:active {
--scale: 2;
transition: --scale 0.5s ease 0s;
}
body:active .scene {
transform: scale3d(1.35, 1.35, 1.35);
transition: all 1s ease 0s;
}
.scene {
width: 40vmin;
height: 40vmin;
display: flex;
align-items: center;
justify-content: center;
transition: all 1s ease 0s;
}
.scene:before {
content: "";
position: absolute;
width: 100%;
height: 100%;
transform: rotateX(75deg) translateZ(-8vmin) rotateZ(320deg);
transform-origin: center center;
border-radius: 100%;
box-shadow: 0 0 10vmin 10vmin #ffffff15;
background: radial-gradient(#fff 5%, #fff2 55%);
filter: blur(5vmin);
animation: shadow 5s ease-in-out 0s infinite;
border: 5vmin dotted #fff2;
}
@keyframes shadow {
0% { transform: rotateX(75deg) translateZ(-47vmin) rotateZ(0deg); }
50% { transform: rotateX(75deg) translateZ(-45vmin) rotateZ(180deg); filter: blur(5vmin) brightness(1.5); }
100% { transform: rotateX(75deg) translateZ(-47vmin) rotateZ(360deg);}
}
.content {
width: 40vmin;
height: 40vmin;
display: flex;
align-items: center;
justify-content: center;
transform: rotateX(-27.5deg) rotateY(-45deg) rotateZ(0deg) scale3d(var(--scale),var(--scale),var(--scale));
transition: all 1s ease 0s;
animation: spin-scene 20s linear 0s infinite;
}
.scene:hover:before,
.content:hover,
.content:hover .diamond .cuboid .side {
animation-play-state: paused;
}
@keyframes spin-scene {
0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale3d(var(--scale), var(--scale), var(--scale)); }
100% { transform: rotateX(360deg) rotateY(-360deg) rotateZ(360deg) scale3d(var(--scale),var(--scale),var(--scale)); }
}
.diamond {
position: absolute;
width: 40vmin;
height: 40vmin;
}
.cuboid {
--height: 41;
--width: 43;
--depth: 45;
--hue: 200;
--sat: 90%;
height: calc(var(--height) * 1vmin);
width: calc(var(--width) * 1vmin);
position: absolute;
animation: cube1 0.6s linear 0s infinite;
transform: translate3d(0vmin, 0vmin, -5vmin);
}
.cuboid .side {
position: absolute;
top: 50%;
left: 50%;
height: 100%;
width: 100%;
border-radius: 2px;
background: hsl(var(--hue), var(--sat), 30%);
opacity: 0.5;
animation: shine 10s ease -5s inf.........完整代码请登录后点击上方下载按钮下载查看
网友评论0