div+css实现三维情人节玫瑰花交互效果代码
代码语言:html
所属分类:布局界面
代码描述:div+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; } body { background-color: #002; min-height: 100vh; display: grid; place-items: center; perspective: 800px; } body * { transform-style: preserve-3d; } .scene { position: relative; transform: rotateX(calc(var(--y, 0) * -40deg)) rotateY(calc(var(--x, 0) * 180deg)); } .floor { position: absolute; inset: -1000px; background-color: sandybrown; background-image: radial-gradient(closest-side, transparent, #002), radial-gradient(Black, 1%, transparent), repeating-linear-gradient(0deg, transparent 0, #0001, transparent 10px), repeating-linear-gradient(60deg, transparent 0, #0001, transparent 10px), repeating-linear-gradient(120deg, transparent 0, #0001, transparent 10px); transform: rotateX(90deg) translateZ(-200px); } .heart { position: absolute; left: 50%; } .heart::after { content: ""; position: absolute; inset: -50px; background-color: var(--color, red); background-image: radial-gradient(#fff4, transparent), linear-gradient(transparent, black); -webkit-clip-path: path("m 50 25 a 25 25 0 0 1 50 0 c 0 25 -50 50 -50 75 c 0 -25 -50 -50 -50 -75 a 25 25 0 0 1 50 0"); clip-path: path("m 50 25 a 25 25 0 0 1 50 0 c 0 25 -50 50 -50 75 c 0 -25 -50 -50 -50 -75 a 25 25 0 0 1 50 0"); } .flower { position: absolute; top: 200px; } .flower i { position: absolute; bottom: 100%; width: 4px; height: 80px; background-color: limegreen; transform-origin: bottom; -webkit-animation: flower 5s infinite ease-in-out alternate; animation: flower 5s infinite ease-in-out alternate; } @-webkit-keyframes flower { from { transform: rotateX(-5deg); } to { transform: rotateX(5deg); } } @keyframes flower { from { transform: rotateX(-5deg); } to { transform: rotateX(5deg); } } .flower .heart:nth-child(1) { transform: rotateY(0deg) rotateX(9deg) translateY(-40px); } .flower .heart:nth-child(2) { transform: rotateY(40deg) rotateX(22deg) translateY(-40px); } .flower .heart:nth-child(3) { transform: rotateY(80deg) rotateX(19deg) translateY(-40px); } .flower .heart:nth-child(4) { transform: rotateY(120deg) rotateX(27deg) translateY(-40px); } .flower .heart:nth-child(5) { transform: rotateY(160deg) rotateX(21deg) translateY(-40px); } .flower .heart:nth-child(6) { transform: rotateY(200deg) rotateX(18deg) translateY(-40px); } .flower .heart:nth-child(7) { transform: rotateY(240deg) rotateX(28deg) translateY(-40px); } .flower .heart:nth-child(8) { transform: rotateY(280deg) rotateX(26deg) translateY(-40px); } .flower .heart:nth-child(9) { transform: rotateY(320deg) rotateX(25deg) translateY(-40px); } .leafs { position: absolute; top: 200px; } .leafs i { position: absolute; bottom: 100%; width: 4px; height: 75%; background-color: limegreen; transform-origin: bottom; transform: rotateX(var(--rx)); } .leafs > i:nth-child(1) { left: -2px; height: 55px; rotate: y 0deg; --rx: 29deg; --color: hsl(120 100% 36); } .leafs > i:nth-child(2) { left: -2px; height: 53px; rotate: y 30deg; --rx: 12deg; --color: hsl(120 100% 23); } .leafs > i:nth-child(3) { left: -2px; height: 50px; rotate: y 60deg; --rx: 37deg; --color: hsl(120 100% 35); } .leafs > i:nth-child(4) { left: -2px; height: 49px; rotate: y 90deg; --rx: 11deg; --color: hsl(120 100% 37); } .leafs > i:nth-child(5) { left: -2px; height: 41px; rotate: y 120deg; --rx: 35deg; --color: hsl(120 100% 37); } .leafs > i:nth-child(6) { left: -2px; height: 78px; rotate: y 150d.........完整代码请登录后点击上方下载按钮下载查看
网友评论0