css布局实现汽车行驶在冲浪海滩公路上动画效果代码

代码语言:html

所属分类:动画

代码描述:css布局实现汽车行驶在冲浪海滩公路上动画效果代码

代码标签: 汽车 行驶 冲浪 海滩 路上 动画 效果

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


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

<head>

  <meta charset="UTF-8">
  

  
<style>
/*
Alittle bit of chaos here... debug in progress
*/

* {
	box-sizing: border-box;
	transform-style: preserve-3d;
	/*animation: none !important;*/
}

body {
	width: 100vw;
	height: 100vh;
	margin: 0;
	padding: 0;
	overflow: hidden;
}

.content {
	perspective: 100vmin;
	transform-style: preserve-3d;
}

.sky {
	background: radial-gradient(
			circle at 50vw 35vh,
			#ffc107 5%,
			rgb(255 193 7 / 64%) 10%,
			rgb(253 50 41 / 50%) 25%,
			rgb(243 0 0 / 40%) 30%,
			rgb(93 0 0 / 0%) 100%
		),
		linear-gradient(180deg, #673ab7, #ffb900 80%, #fff0 100%);
	width: 100vw;
	height: 35vh;
	position: absolute;
	left: 0;
	top: 0;
}
.sky:after {
	content: "";
	width: 100%;
	height: 5vmin;
	position: absolute;
	background: linear-gradient(
		to top,
		rgba(0, 25, 45, 1) 0%,
		rgba(14, 71, 117, 1) 35%,
		rgba(26, 126, 174, 1) 70%,
		rgba(62, 168, 220, 1) 100%
	);
	bottom: 0;
	box-shadow: 0 6px 6px -6px #ffc107 inset;
}

/*
.water {
  background: 
  height: 50vh;
  overflow: hidden;
  position: relative;
}
.water:before {
  content: "";
  width: 100%;
  height: 100%;
  position: absolute;
  background: repeating-linear-gradient(175deg,rgba(165,165,165,0.08) 45%, rgba(175,175,175,0.08) 47%, rgba(235,235,235,0.08) 50%, rgba(195,195,195,0.08) 54%, rgba(165,165,165,0.08) 57%), linear-gradient(to left top, rgba(0,0,0,0.0) 10%,rgba(0,0,0,0.20) 44%,rgba(0,0,0,0.65) 95%,rgba(0,0,0,0.62) 100%);
  opacity: 0.5;
  box-shadow: 0 6px 6px -6px #ffc107 inset;
  animation: ocean 15s infinite;
}
*/

.ground {
	background: linear-gradient(
		to top,
		#0a190b 0%,
		#255226 36%,
		#8bc34a 98%,
		#1e6f20b3 100%
	);
	width: 300vw;
	height: 70vh;
	position: absolute;
	left: -100vw;
	top: 30vh;
	border-radius: 100% 100% 0 0;
}

.road {
	background: linear-gradient(0deg, #6d6d6d, #eae5d6);
	width: 25vw;
	height: 70vh;
	position: absolute;
	top: 30vh;
	left: 35vw;
	transform: rotateX(90deg);
	transform-origin: center top;
	border-radius: 1% 1% 0 0;
	animation: roadview 10s ease-in-out 0s infinite alternate;
	border: 0.25vmin solid #75747470;
	border-top: 0;
	border-bottom: 0;
}

@keyframes roadview {
	0% {
		left: 49vw;
	}
	10% {
		left: 48vw;
	}

	40% {
		left: 40vw;
	}
	70% {
		left: 30vw;
	}

	90% {
		left: 19vw;
	}
	100% {
		left: 18vw;
	}
}

.road:before,
.road:after {
	content: "";
	width: 1vmin;
	height: 100%;
	background: #ffffffba;
	position: absolute;
	left: 1.25vmin;
}

.road:after {
	left: initial;
	right: 1.25vmin;
}

.line {
	width: 1vmin;
	height: 100%;
	background: repeating-linear-gradient(0deg, #fff 0 25%, transparent 0 50%);
	position: absolute;
	left: calc(50% - 0.625vmin);
	animation: gradient 2s linear 0s infinite;
	background-size: 1vmin 20vmin;
	background-position: 50% 0%;
}

@keyframes gradient {
	0% {
		background-position: 0% 0%;
	}
	100% {
		background-position: 0% 100%;
	}
}

.van {
	/*background: #ccc;*/
	width: 16vw;
	height: 26vmin;
	position: absolute;
	bottom: 0vmin;
	bottom: -3vh;
	z-index: 22222;
	transform: translateZ(4.15vmin) translateY(-8vmin) rotateZ(0deg);
	transform-style: preserve-3d;
	perspective: 100vmin;
	--height: 16;
	--width: 8;
	--depth: 6;
	--hue: 0;
	--sat: 60%;
	height: calc(var(--height) * 1vmin);
	width: calc(var(--width) * 1vmin);
	perspective-origin: center;
	left: calc(50% - -3vmin);
	animation: vanmove 3s ease 0s infinite alternate;
}

@keyframes vanmove {
	0% {
		transform: translateZ(4.15vmin) translateY(-8vmin) rotateZ(0deg) rotateY(1deg);
	}
	20% {
		transform: translateZ(4.15vmin) translateY(-8vmin) rotateZ(1deg) rotateY(0deg);
	}
	40% {
		transform: translateZ(4.15vmin) translateY(-8vmin) rotateZ(0deg)
			rotateY(-1deg);
	}
	60% {
		transform: translateZ(4.15vmin) translateY(-8vmin) rotateZ(-1deg)
			rotateY(0deg);
	}
	80% {
		transform: translateZ(4.15vmin) translateY(-8vmin) rotateZ(0deg) rotateY(1deg);
	}
	100% {
		transform: translateZ(4.15vmin) translateY(-8vmin) rotateZ(1deg) rotateY(0deg);
	}
}

.line + .van:before {
	background: #333;
	width: 98%;
	height: 60%;
	position: absolute;
	content: "";
	top: 40%;
	left: 1%;
	background-color: #026873;
	background-image: linear-gradient(
			90deg,
			rgba(255, 255, 255, 0.07) 50%,
			transparent 50%
		),
		linear-gradient(90deg, rgba(255, 255, 255, 0.13) 50%, transparent 50%),
		linear-gradient(90deg, transparent 50%, rgba(255, 255, 255, 0.17) 50%),
		linear-gradient(90deg, transparent 50%, rgba(255, 255, 255, 0.19) 50%);
	background-size: 1vmin, 1.5vmin, 1.8vmin, 2.2vmin;
}

.side {
	position: absolute;
	top: 50%;
	left: 50%;
	height: 100%;
	width: 100%;
	border-radius: 0.25vmin;
}

.side:nth-of-type(1) {
	transform: translate3d(-50%, -45%, calc(var(--depth) * 0.5vmin));
	background: hsl(var(--hue), var(--sat), 50%);
	height: 91%;
}
.side:nth-of-type(2) {
	transform: translate3d(-50%, -50%, calc(var(--depth) * -0.5vmin))
		rotateY(180deg);
	background: hsl(var(--hue), var(--sat), 35%);
}
.side:nth-of-type(3) {
	width: calc(var(--depth) * 1vmin);
	transform: translate(-50%, -50%) rotateY(90deg)
		translate3d(0, 0, calc(var(--width) * 0.5vmin));
	background: linear-gradient(
			0deg,
			transparent 0% 38%,
			#000 0% 38.25%,
			transparent 38.5% 69%,
			#000 69.25%,
			transparent 69.45% 100%
		),
		hsl(var(--hue), var(--sat), 40%);
	clip-path: polygon(
		0 10%,
		45% 5%,
		60% 0,
		100% 0%,
		100% 100%,
		4% 100%,
		4% 98%,
		45% 98%,
		45% 9%,
		7% 13%,
		7% 100%,
		0% 100%
	);
}
.side:nth-of-type(4) {
	width: calc(var(--depth) * 1vmin);
	transform: translate(-50%, -50%) rotateY(90deg)
		translate3d(0, 0, calc(var(--width) * -0.5vmin));
	background: linear-gradient(
			180deg,
			transparent 0% 30.1%,
			#000 0% 30.5%,
			transparent 31% 100%
		),
		hsl(var(--hue), var(--sat), 60%);
	clip-path: polygon(
		0 10%,
		45% 5%,
		60% 0,
		100% 0%,
		100% 100%,
		4% 100%,
		4% 98%,
		45% 98%,
		45% 9%,
		7% 13%,
		7% 100%,
		0% 100%
	);
}
.side:nth-of-type(5) {
	height: calc(var(--depth) * 0.5vmin);
	transform: translate(-50%, -50%) rotateX(75deg)
		translate3d(0vmin, -0.3vmin, calc(var(--height) * 0.435vmin)) rotate(180deg);
	background: hsl(var(--hue), var(--sat), 70%);
	clip-path: polygon(
		0% 0%,
		0% 100%,
		5% 100%,
		5% 11%,
		95% 10%,
		95% 90%,
		5% 90%,
		5% 100%,
		100% 100%,
		100% 0%
	);
}
.side:nth-of-type(6) {
	height: calc(var(--depth) * 0.19vmin);
	transform: translate(-50%, -50%) rotateX(-135deg)
		translate3d(0vmin, 5.5vmin, calc(var(--height) * -0.3275vmin));
	background: hsl(var(--hue), var(--sat), 70%);
	border-radius: 0.15vmin;
}
.side:nth-of-type(7) {
	height: calc(var(--depth) * 1vmin);
	transform: translate(-50%, -50%) rotateX(-90deg)
		translate3d(0, 0, calc(var(--height) * 0.5vmin));
	background: hsl(var(--hue), var(--sat), 30%);
	clip-path: polygon(
		0% 0%,
		0% 100%,
		5% 100%,
		5% 5%,
		95% 5%,
		95% 45%,
		5% 45%,
		5% 100%,
		100% 100%,
		100% 0%
	);
}

.side:nth-of-type(6):before {
	width: 100%;
	height: 220%;
	position: absolute;
	content: "";
	background: hsl(var(--hue), var(--sat), 57%);
	bottom: -15%;
	transform: rotateX(45deg) translate3d(0vmin, 2vmin, -0.8vmin);
	border-radius: 0.1vmin;
}

/* front-back glass */
.side:nth-of-type(1):before,
.side:nth-of-type(1):after {
	content: "";
	width: 91%;
	height: 16.5%;
	background: linear-gradient(
			45deg,
			transparent 0 30%,
			#ffffff30 31% 35%,
			transparent 36% 40%,
			#ffffff20 41% 43%,
			transparent 42% 50%
		),
		#03a9f442;
	z-index: 2;
	float: left;
	transform: rotateX(90deg) translate3d(5%, -1.55vmin, -13.35vmin);
	bottom: 0;
}

/* front glass */
.side:nth-of-type(1):after {
	transform: rotateX(75deg) translate3d(4.5%, -2.4vmin, 3.35vmin);
	height: 17%;
}

.side:nth-of-type(2):before,
.side:nth-of-type(2):after {
	content: "";
	width: 30%;
	height: 89%;
	background: linear-gradient(
			0deg,
			transparent 0% 40.9%,
			#0004 0% 41.5%,
			transparent 41.85% 75.5%,
			#0007 76.25%,
			transparent 69.45% 100%
		),
		linear-gradient(
			-25deg,
			transparent 0 9%,
			#ffffff20 10% 12%,
			transparent 12% 14%,
			#ffffff20 15% 17%,
			transparent 18% 20%
		),
		linear-gradient(
			0deg,
			#03a9f442 0 40%,
			hsl(var(--hue), var(--sat), 35%) 0 43%,
			#03a9f442 0% 75%,
			hsl(var(--hue), var(--sat), 35%) 0% 78%,
			#03a9f442 0% 100%
		);
	z-index: 2;
	float: left;
	transform: rotateX(0deg) rotateY(90deg)
		translate3d(4.5vmin, 1.5vmin, -1.15vmin);
	bottom: 0;
}
.side:nth-of-type(2):after {
	transform: rotateX(0deg) rotateY(90deg)
		translate3d(4.5vmin, 1.5vmin, 4.425vmin);
	background: linear-gradient(
			180deg,
			transparent 0% 23.5%,
			#0008 0% 24%,
			transparent 24.5% 100%
		),
		linear-gradient(
			-25deg,
			transparent 0 9%,
			#ffffff20 10% 12%,
			transparent 12% 14%,
			#ffffff20 15% 17%,
			transparent 18% 20%
		),
		linear-gradient(
			0deg,
			#03a9f442 0 40%,
			hsl(var(--hue), var(--sat), 60%) 0 43%,
			#03a9f442 0% 75%,
			hsl(var(--hue), var(--sat), 60%) 0% 78%,
			#03a9f442 0% 100%
		);
}

.van.shadow {
	transform: translate3d(0vmin, -9vmin, 0vmin);
	background: #00000080;
	filter: blur(8px);
	animation: none;
}

.van.wheels div,
.van.wheels div span {
	background: radial-gradient(#121212 0% 30%, #333 0 55%, #fff 60%, #333 65%);
	width: 2.75vmin;
	height: 3vmin;
	position: absolute;
	transform: rotateY(90deg) translate3d(3vmin, 2.5vmin, -1.65vmin);
	border-radius: 90% 100%;
	box-shadow: 0 0 2px 0 #111 inset;
}

.van.wheels div {
	animation: wheelspin 0.25s linear 0s infinite alternate;
}

.van.wheels div span {
	transform: rotateY(0deg) translate3d(0vmin, 0vmin, 0.05vmin);
	background: #333;
	width: 100%;
	height: 100%;
}
.van.wheels div span:nth-child(2) {
	transform: rotateY(0deg) translate3d(0vmin, 0vmin, 0.1vmin);
}
.van.wheels div span:nth-child(3) {
	transform: rotateY(0deg) translate3d(0vmin, 0vmin, 0.15vmin);
}
.van.wheels div span:nth-child(4) {
	transform: rotateY(0deg) translate3d(0vmin, 0vmin, 0.2vmin);
}
.van.wheels div span:nth-child(5) {
	transform: rotateY(0deg) translate3d(0vmin, 0vmin, 0.25vmin);
}
.van.wheels div span:nth-child(6) {
	transform: rotateY(0deg) translate3d(0vmin, 0vmin, 0.3vmin);
}
.van.wheels div span:nth-child(7) {
	transform: rotateY(0deg) translate3d(0vmin, 0vmin, 0.35vmin);
}
.van.wheels div span:nth-child(8) {
	transform: rotateY(0deg) translate3d(0vmin, 0vmin, 0.4vmin);
}
.van.wheels div span:nth-child(9) {
	transform: rotateY(0deg) translate3d(0vmin, 0vmin, 0.45vmin);
}
.van.wheels div span:nth-child(10) {
	transform: rotateY(0deg) translate3d(0vmin, 0vmin, 0.5vmin);
}

.van.wheels div:nth-child(2) {
	transform: rotateY(-90deg) translate3d(-3vmin, 2.5vmin, -7vmin);
}
.van.wheels div:nth-child(3) {
	transform: rotateY(90deg) translate3d(3vmin, 11vmin, -1.65vmin);
	animation-delay: 0.1s;
}
.van.wheels div:nth-child(4) {
	transform: rotateY(-90deg) translate3d(-3vmin, 11vmin, -7vmin);
}

@keyframes wheelspin {
	0% {
		width: 2.75vmin;
	}
	100% {
		width: 2.675vmin;
	}
}

/*porton*/
/*
.side:nth-of-type(7):before {
    background: #fff;
    content: "6543BR";
    position: absolute;
    bottom: 1.75vmin;
    font-size: 0.5vmin;
    border-left: 0.5vmin solid #2121ff;
    left: calc(50% - 1.25vmin);
    min-width: 2.5vmin;
    box-sizing: border-box;
    box-shadow: 0.025vmin -0.1vmin 0 0vmin #000;
}
*/

.side:nth-of-type(7):after {
	background: #292929;
	content: "";
	position: absolute;
	bottom: 2.5vmin;
	left: calc(50% - 0.3vmin);
	width: 0.25vmin;
	height: 0.2vmin;
	border-radius: 5px;
	border: 1px solid #000;
	box-shadow: 0 0 1px 0 #000;
}

.signal {
	background: #28a0ff;
	width: 10vmin;
	height: 5vmin;
	position: absolute;
	right: -12vmin;
	transform: rotateX(-90deg) translate3d(2vmin, 0, -100vmin);
	border-radius: 0.35vmin;
	border: 0.35vmin solid #e7fcff;
	font-family: Arial, Helvetica, sans-serif;
	color: #fff;
	font-weight: bold;
	font-size: 1.75vmin;
	padding: 1vmin 0.5vmin;
	text-align: center;
	animation: signalview 14s linear 0s infinite;
}

@keyframes signalview {
	0%,
	20% {
		transform: rotateX(-90deg) translate3d(2vmin, 0, -100vmin);
	}
	20% {
		transform: rotateX(-90deg) translate3d(2vmin, 0, -27vmin);
	}
	40%,
	100% {
		transform: rotateX(-90deg) translate3d(2vmin, 0, 100vmin);
	}
}

.signal:before,
.signal:after {
	content: "";
	background: linear-gradient(90deg, #ccc, #666, #333, #212121, #121212, #333);
	width: 1vmin;
	height: 5vmin;
	position: absolute;
	top: 4.6vmin;
	border-radius: 0 0 0.15vmin 0.15vmin;
}

.signal:after {
	right: 1.15vmin;
}

.signal span {
	width: 10vmin;
	height: 5vmin;
	position: absolute;
	top: 4.5vmin;
	border-radius: 0.35vmin;
	border-top: 5vmin solid black;
	background: linear-gradient(
		90deg,
		transparent 0 17%,
		#000 0% 26%,
		#fff0 0% 75%,
		#000 0% 84%,
		#fff0 0% 100%
	);
	transform: translate3d(-7vmin, -5vmin, 0vmin) rotateX(-90deg) skewX(-12deg);
	transform-origin: center bottom;
	filter: blur(1px);
	opacity: 0.25;
	box-sizing: initial;
}

.signal + .signal {
	border-width: 0.3vmin;
	animation-delay: 7s;
	background: #fc0;
	color: #222;
	height: 2.5vmin;
	text-transform: uppercase;
	font-size: 1.25vmin;
	padding: 0.25vmin;
	border-color: #222;
	box-shadow: 0 0 0 0.25vmin #fc0;
	width: 9vmin;
}

.signal + .signal:before {
	height: 15vmin;
	transform: translateX(3vmin) translateY(-12.5vmin) translateZ(-0.1vmin);
}

.signal + .signal:after {
	background: linear-gradient(
		90deg,
		transparent 0 43%,
		#000 0% 53%,
		#fff0 0% 100%
	);
	width: 10vmin;
	transform: translate3d(1.25vmin, -8.25vmin, 1vmin) rotateX(-90deg)
		skewX(-12deg);
	filter: blur(1px);
	opacity: 0.25;
	transform-origin: center bottom;
	font-size: 8vmin;
	color: #000;
	line-height: 1vmin;
	content: "\25C6 \2582";
	height: 10vmin;
	width: 9vmin;
	white-space: pre;
	content: "\25C6 \A \2582";
}

.signal + .signal span {
	display: block;
	content: " ";
	position: absolute;
	background: #ffcc00;
	width: 5vmin;
	height: 5vmin;
	left: 1.55vmin;
	top: -7vmin;
	transform: rotate(45deg) translate3d(-1.65vmin, 0.75vmin, 0vmin);
	border: 0.25vmin solid #222;
	box-sizing: border-box;
	box-shadow: 0 0 0 0.2vmin #fc0;
	opacity: 1;
	filter: none;
	text-align: center;
	padding: 2vmin;
	font-size: 1.5vmin;
}

.signal + .signal span:before {
	content: "";
	background: linear-gradient(0deg, #222 45%, transparent 45% 55%, #222 0% 100%);
	width: 3.5vmin;
	height: 1vmin;
	position: absolute;
	border-radius: 100% 65% 65% 100%;
	transform: rotateZ(121deg);
	top: 1.15vmin;
	left: 0vmin;
}

.signal + .signal span:after {
	width: 3.5vmin;
	font-size: 2vmin;
	position: absolute;
	content: "";
	top: 1.5vmin;
	left: 1.05vmin;
	transform: rotate(-45deg);
	content: &.........完整代码请登录后点击上方下载按钮下载查看

网友评论0