纯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;
}
:root {
--pos0: 35px;
--pos1: -80px;
--pos2: 105px;
--pos3: -10px;
--pos4: -125px;
--pos5: 60px;
--pos6: -55px;
--pos7: 130px;
--pos8: 15px;
--pos9: -100px;
--pos10: 85px;
--pos11: -30px;
--pos12: -145px;
--pos13: 40px;
--pos14: -75px;
--pos15: 110px;
}
body {
font-family: "Montserrat", sans-serif;
background-color: #111;
color: #fff;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
perspective: 1800px;
perspective-origin: 40% calc(50% - 360px);
overflow: hidden;
}
.container {
position: absolute;
top: calc(50% + 0px);
transform-style: preserve-3d;
-webkit-animation: rotate 80s linear infinite;
animation: rotate 80s linear infinite;
}
@-webkit-keyframes rotate {
to {
transform: rotateY(-360deg);
}
}
@keyframes rotate {
to {
transform: rotateY(-360deg);
}
}
.floor {
position: absolute;
width: 100vmax;
height: 100vmax;
background-image: radial-gradient(#000d, #0000 33%, #111 66%), repeating-linear-gradient(#afa3 0, transparent 1px 40px, #afa3 41px), repeating-linear-gradient(to left, #afa3 0, transparent 1px 40px, #afa3 41px);
transform: translate(-50%, -50%) rotateX(90deg) translateZ(-180px);
}
.leg {
position: absolute;
transform-style: preserve-3d;
transform: rotateX(-90deg);
transform-origin: top;
}
.leg:nth-child(1) {
top: 36px;
left: 36px;
}
.leg:nth-child(2) {
top: 36px;
right: 36px;
}
.leg:nth-child(3) {
top: 324px;
left: 36px;
}
.leg:nth-child(4) {
top: 324px;
right: 36px;
}
.leg::after {
content: "";
position: absolute;
top: 18px;
left: -18px;
width: 36px;
height: 162px;
background-image: linear-gradient(#111, #1111), linear-gradient(to left, #222, #777, #222);
border-radius: 0 0 50% 50%/0 0 5px 5px;
animation: rotate 80s linear infinite reverse;
}
.table {
position: absolute;
top: -180px;
left: -360px;
height: 360px;
width: 720px;
background-color: #066;
background-image: radial-gradient(#fff1, #0003), linear-gradient(to left, #fff 6px, #fff0 6px calc(100% - 6px), #fff calc(100% - 6px)), linear-gradient(#fff 6px, #fff0 6px calc(50% - 3px), #fff calc(50% - 3px) calc(50% + 3px), #fff0 calc(50% + 3px) calc(100% - 6px), #fff calc(100% - 6px));
transform: rotateX(90deg);
transform-style: preserve-3d;
}
.table > .net {
position: absolute;
width: 5%;
height: 100%;
left: 50%;
transform: rotateY(-90deg);
transform-origin: left;
transform-style: preserve-3d;
background-image: repeating-linear-gradient(45deg, #aaa 0 1px, #aaa0 1px 4px), repeating-linear-gradient(135deg, #aaa 0 1px, #aaa0 1px 4px);
border: 2px soli.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0