css+div实现花岗岩三角形错觉立体多边形动画效果代码

代码语言:html

所属分类:动画

代码描述:css+div实现花岗岩三角形错觉立体多边形动画效果代码

代码标签: css div 花岗岩 三角形 错觉 立体 多边形 动画

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

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

<head>
  <meta charset="UTF-8">
  

  
  
  
<style>
* {
	transform-style: preserve-3d;
}

body {
	margin: 0;
	height: 100vh;
	background: linear-gradient(315deg, #0d0a0b 0%, #004942 74%);
	background: radial-gradient(circle at 50% 25%, #004942, #02111c);
	display: flex;
	justify-content: center;
	align-items: center;
	overflow: hidden;
}

body:before {
	content: "";
	position: absolute;
	width: 100%;
	height: 100%;
	background:	
		repeating-conic-gradient(#0003 0%, #fff0 .00033%, #fff0 .00066%,  #fff0 .00099%),
		repeating-conic-gradient(#fff2 0%, #fff0 .0005%, #fff0 .0015%, #fff0 .019%);
	filter:blur(1px);
}

.content {
	width: 90vmin;
	height: 60vmin;
	margin: 0 auto;
	justify-content: center;
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	align-content: center;
	perspective: 1500vmin;
	perspective-origin: center;
	filter: drop-shadow(-8vmin 12vmin 2vmin #0002);
}

.shape {
	transform: rotateX(-35deg) rotateY(-45deg);
	transition: all 2s ease-in-out 0s;
	animation: move 1.95s ease-in-out 0s 2 alternate;
	position: relative;
	top: -15vmin;
}

@keyframes move {
	0% { transform: rotateX(-35deg) rotateY(-45deg); }
	100% { transform: rotateX(-20deg) rotateY(-125deg) translateZ(-22vmin) translateY(5vmin); }
}

.content:hover .shape {
	transform: rotateX(-20deg) rotateY(-125deg) translateZ(-22vmin) translateY(5vmin);
	transition: all 2s ease-in-out 0s;
}

.content:hover .shape .cube .side:nth-of-type(2) {
	background: hsl(var(--hue), var(--sat), 80%);
}

.content:hover .shape .cube .side:nth-of-type(3) {
	background: hsl(var(--hue), var(--sat), 30%);
}

.cube {
	--width: 10;
	--height: 10;
	--depth: 10;
	height: calc(var(--height) * 1vmin);
	width: calc(var(--width) * 1vmin);
	--hue: 150;
	--sat: 25%;
	position: absolute;
}

.side {
	position: absolute;
	top: 50%;
	left: 50%;
	height: 100%;
	width: 100%;
	box-sizing: border-box;
}

.side:before, .side:after {
	content: "";
	position: absolute;
	width: 100%;
	height: 100%;
	background:	
		repeating-conic-gradient(#0003 0%, #fff0 .0003%, #fff0 .0006%,  #fff0 .00099%),
		repeating-conic-gradient(#fff2 0%, #fff0 .0005%, #fff0 .0015%, #fff0 .019%);
	background-size: 102% 102%;
	filter: blur(0.5px);
}

.side:after {
	filter: blur(2px);
}

@keyframes light {
	0% { background: hsl(var(--hue), var(--sat), 40%); }
	100% { background: hsl(var(--hue), var(--sat), 80%); }
}

.side:nth-of-type(1) {
	transform: translate3d(-50%, -50%, calc(var(--depth) * 0.5vmin));
	background: hsl(var(--hue), var(--sat), 40%);
}

.side:nth-of-type(2) {
	transform: translate3d(-50%, -50%, calc(var(--depth) * -0.5vmin))
		rotateY(180deg);
	background: hsl(var(--hue), var(--sat), 30%);
	animation: light 1.95s ease-in 0s 2 alternate;
	transition: all 1.95s ease-in 0s;
}

.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: hsl(var(--hue), var(--sat), 80%);
	animation: light 1.95s ease-in 0s 2 alternate-reverse;
	transition: all 1.95s ease-in 0s;
}

.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: hsl(var(--hue), var(--sat), 70%);
}

.side:nth-of-type(5) {
	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), 60%);
}

.side:nth-of-type.........完整代码请登录后点击上方下载按钮下载查看

网友评论0