css实现一个三维牛顿摆动画效果代码
代码语言:html
所属分类:三维
代码描述:css实现一个三维牛顿摆动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
*, *::before, *::after {
padding: 0;
margin: 0 auto;
box-sizing: border-box;
transform-style: preserve-3d;
}
body {
background-color: #111;
color: #fff;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-size: 50px;
perspective: 800px;
perspective-origin: center calc(50% - 2.4em);
overflow: hidden;
}
.cradle {
position: relative;
-webkit-animation: rotate 60s infinite linear;
animation: rotate 60s infinite linear;
}
@-webkit-keyframes rotate {
to {
transform: rotateY(360deg);
}
}
@keyframes rotate {
to {
transform: rotateY(360deg);
}
}
.floor {
position: absolute;
width: 20em;
height: 20em;
background-color: #fff;
background-image: radial-gradient(#012a, #111 66%), url("//repo.bfw.wiki/bfwrepo/image/6032e554eeb71.png");
background-size: 20em, 10em;
transform: translate(-50%, -50%) rotateX(90deg) translateZ(-3em);
}
.floor::after {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 8.5em;
height: 4.5em;
background-color: #000;
filter: blur(0.3em);
}
.wood {
--width: 0;
--height: 0;
--depth: 0;
position: absolute;
top: 0;
left: 0;
width: var(--width);
height: var(--height);
transform: translate(-50%, -50%);
}
.wood.base {
--width: 8em;
--height: 1em;
--depth: 4em;
transform: translate(-50%, calc(-50% + 2.5em));
}
.wood.poll {
--width: 0.25em;
--height: 3em;
--depth: 0.25em;
}
.wood.poll:nth-child(3) {
transform: translate3d(calc(-50% + 3.5em), calc(-50% + 0.5em), 1.5em);
}
.wood.poll:nth-child(4) {
transform: translate3d(calc(-50% + 3.5em), calc(-50% + 0.5em), -1.5em);
}
.wood.poll:nth-child(5) {
transform: translate3d(calc(-50% + -3.5em), calc(-50% + 0.5em), 1.5em);
}
.wood.poll:nth-child(6) {
transform: translate3d(calc(-50% + -3.5em), calc(-50% + 0.5em), -1.5em);
}
.wood.strecher {
--width: 8em;
--height: 0.25em;
--depth: 1em;
}
.wood.strecher:nth-child(7) {
transform: translate3d(-50%, calc(-50% - 1em), 1.5em);
}
.wood.strecher:nth-child(8) {
transform: translate3d(-50%, calc(-50% - 1em), -1.5em);
}
.wood.strecher .dots::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: radial-gradient(circle at 76% 50%, #777 0px, #7770 2px), radial-gradient(circle at 63% 50%, #777 0px, #7770 2px), radial-gradient(circle at 50% 50%, #777 0px, #7770 2px), radial-gradient(circle at 37% 50%, #777 0px, #7770 2px), radial-gradient(circle at 24% 50%, #777 0px, #7770 2px);
}
.wood > * {
position: absolute;
box-shadow: 0 0 1em #0007 inset;
background-size: 5em;
background-image: url("https://assets.codepen.io/1948355/wood04.png");
}
.wood > .top {
width: var(--width);
height: var(--depth);
.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0