css实现三维线球在圆板上来回运动动画效果代码

代码语言:html

所属分类:动画

代码描述:css实现三维线球在圆板上来回运动动画效果代码

代码标签: css 三维 线球 圆板 来回 运动

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  
  
  
<style>
:root {
	--speed: 3.5s;
}

* {
    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: 100vmin;
    background: radial-gradient(circle at 50% -50%, #607d8b 15%, #000000 100%);
}

.content {
	width: 90vmin;
    height: 90vmin;
    /*background: #99000040;*/
    transform: rotateX(45deg) translateY(-10vmin);
}

.content * {
	position: absolute;
}

.base {
	width: 90vmin;
	height: 90vmin;
	background: radial-gradient(circle at 49% 48%, #795548 34%, #422d25 60%, #0009 62% 63%, #422d25 66%, #000 73%);	
	border-radius: 100%;
}

.base:before, .base:after {
	content: "";
    background: radial-gradient(#503930 0 55%, #cf927d);
    width: calc(100% - 4vmin);
    height: calc(100% - 4vmin);
    position: absolute;
    border-radius: 100%;
    transform: translateZ(3vmin);
    left: 2vmin;
    top: 2vmin;
    box-shadow: 0 0 5vmin 0vmin #0008 inset;
	border: 1px solid #795548;
    box-sizing: border-box;
}

.base:after {
	--lines: #fff0 49.75%, #795548 50%, #fff0 50.25%;
    background: 
		radial-gradient(#795548 60%, #fff0 calc(60% + 1px)), 
		linear-gradient(0deg, var(--lines)), 
		linear-gradient(10deg, var(--lines)), 
		linear-gradient(20deg, var(--lines)), 
		linear-gradient(30deg, var(--lines)), 
		linear-gradient(40deg, var(--lines)), 
		linear-gradient(50deg, var(--lines)), 
		linear-gradient(60deg, var(--lines)), 
		linear-gradient(70deg, var(--lines)), 
		linear-gradient(80deg, var(--lines)), 
		linear-gradient(90deg, var(--lines)), 
		linear-gradient(100deg, var(--lines)), 
		linear-gradient(110deg, var(--lines)), 
		linear-gradient(120deg, var(--lines)), 
		linear-gradient(130deg, var(--lines)), 
		linear-gradient(140deg, var(--lines)), 
		linear-gradient(150deg, var(--lines)), 
		linear-gradient(160deg, var(--lines)), 
		linear-gradient(170deg, var(--lines));
}


	
.pendulum {
	background: linear-gradient(90deg, #fff0 49.75%, #fff0 49.75% 50.25%, #fff0 50.25%);
    width: 100%;
    height: 100%;
	display: flex;
    align-items: center;
    justify-content: center;
	
	transition: all 60s linear 0s;
    transform: rotate(360deg);
	
	animation: earth-rotation 253.5s linear 0s infinite;
	
}

@keyframes earth-rotation {
	0% { transform: rotate(360deg); }
	100% { transform: rotate(0deg); }
}

.axis {
    /*background: #00800075;*/
    width: 9vmin;
    height: 500vmin;
    transform: rotateX(90deg) translateY(253vmin);
	
}





.rope {
    background: linear-gradient(90deg, #fff0 49%, #9d9d9d 49% 51%, #fff0 51%);
    width: 9vmin;
    height: 100%;
	animation: swing 3.5s ease-in-out 0s infinite alternate;
}

@keyframes swing {
	0% { transform: rotateZ(-10deg); }
	100% { transform: rotateZ(10deg); }
}

.rope:before, .rope:after {
    content: "";
    position: absolute;
    width: 2%;
    left: 49%;
    height: 110%;
    background: linear-gradient(90deg, #fff0 49%, #9d9d9d 49% 51%, #fff0 51%);
    transform: rotateY(120deg);
    border: 1px solid #ffffff70;
    box-sizing: border-box;
    top: -10%;
}

.rope:after {
    transform: rotateY(240deg);
}






.ball {
    background: radial-gradient(circle at 50% 0%, #6666, #ccc2);
    width: 100%;
    height: 9vmin;
    border-radius: 100%;
    top: 3.1vmin;
	box-shadow: inset 0 0 0 1px #c1c1c188;
}


.ball:before, .ball:after {
    content: "";
    position: absolute;
    width: 7vmin;
    height: 7vmin;
    border-radius: 100%;
    transform: rotateX(90deg) translateZ(6.5vmin) translate(1vmin, 1vmin);
    box-shadow: 0 0 3vmin 0vmin #0003;
    filter: blur(5px);
    background: radial-gradient(#0006, #fff0);
	opacity: 0.75;
}

.ball:after {
    width: 9vmin;
    height: 9vmin;
    border-radius: 100%;
    transform: rotateX(90deg) translateZ(6.5vmin) translate(0vmin, 0vmin);
    box-shadow: 0 0 3vmin 2vmin #0002;
}

.ball span {
	background: radial-gradient(circle at 50% 0%, #6666, #ccc2);
    width: 100%;
    height: 9vmin;
    border-radius: 100%;
    border: 1px solid #c1c1c188;
}
.ball span:nth-child(1) {
	transform: rotateY(10deg)
}
.ball span:nth-child(2) {
	transform: rotateY(20deg)
}
.ball span:nth-child(3) {
	transform: rotateY(30deg)
}
.ball span:nth-child(4) {
	transform: rotateY(40deg)
}
.ball span:nth-child(5) {
	transform: rotateY(50deg)
}
.ball span:nth-child(6) {
	transform: rotateY(60deg)
}
.ball span:nth-child(7) {
	transform: rotateY(70deg)
}
.ball span:nth-child(8) {
	transform: rotateY(80deg)
}
.ball span:nth-child(9) {
	transform: rotate.........完整代码请登录后点击上方下载按钮下载查看

网友评论0