css+div布局实现礼盒点击打开三维效果代码
代码语言:html
所属分类:三维
代码描述:css+div布局实现礼盒点击打开三维效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url("https://fonts.googleapis.com/css2?family=Mountains+of+Christmas:wght@400;700&family=Noto+Color+Emoji&display=swap"); :root { --rotate-speed: 50s; --primary-col: #001f3f; --secondary-col: #3a6d8c; --tertiary-col: #6a9ab0; } div { transition: transform 0.6s ease, box-shadow 0.6s ease; } body { font-family: "Noto Color Emoji", sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #1d1e22; font-size: 16px; } p { text-align:center; font-size: 3rem; color: white; font-family: "Mountains of Christmas", serif; font-weight: 700; font-style: normal; display: none; color: var(--tertiary-col); text-shadow: 2px 2px 4px var(--primary-col), 0 0 2px var(--primary-col), 0 0 1px var(--primary-col), 3px 3px 5px white, 0 0 3px white, 0 0 2px white; } .active p { display: flex; } span { font-size: 3rem; text-align:center; font-weight: 400; font-style: normal; } .cube-container { width: 200px; height: 200px; perspective: 600px; } .cube { width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateX(-30deg) rotateY(45deg); animation: rotate var(--rotate-speed) infinite linear; transition: transform 0.6s; } @keyframes rotate { from { transform: rotateX(-30deg) rotateY(45deg) rotateY(-45deg); } to { transform: rotateX(-30deg) rotateY(45deg) rotateY(405deg); } } .other { background: none !important; border: none !important; display: flex !important; place-items: center; place-content: center; } #gift { animation: anti-rotate-gift var(--rotate-speed) infinite linear; width: fit-content !important; } @keyframes anti-rotate-gift { to { transform: rotateX(-30deg) rotateY(45deg) rotateY(-405deg); } } #bow { width: fit-content !important; font-size: 5em; transform: translateX(-45px) translateY(-105px) rotateX(60deg) rotateY(-45deg); } .cube.active #bow { animation: fly-up-bow 0.6s forwards; } @keyframes fly-up-bow { 100% { transform: translateX(-45px) translateY(-235px) rotateX(60deg) rotateY(-45deg); } } .cube > div.lil { height: 10%; } .cube > div { position: absolute; width: 100%; height: 100%; background: radial-gradient( transparent 0, transparent 20px, #dc143c 0, #dc143c 25px, transparent 0, transparent 100% ), radial-gradient( transparent 0, transparent 20px, #dc143c 0, #dc143c 25px, transparent 0, transparent 100% ), radial-gradient( transparent 0, transparent 20px, #3cb371 0, #3cb371 25px, transparent 0, transparent 100% ), radial-gradient( transparent 0, transparent 20px, #3cb371 0, #3cb371 25px, transparent 0, transparent 100% ), #fde4e3; /* , linear-gradient(135deg, #5bf2f5 5%, #5bf2f5 15%); */ background-blend-mode: multiply; background-size: 80px 80px; background-position: 40px 40px, 40px 0, 0 0, 0 40px; border: 1.5px solid black; } .top { transform: rotateX(90deg) translateZ(100px); } .top h1 { transform: rotateX(90deg) translateZ(200px); } .cube.active .top { animation: fly-up 0.6s forwards; } @keyframes fly-up { 100% { transform: rotateX(90deg) translateZ(230px); } } .top-back { transform: rotateY(180deg) translateZ(100px); } .cube.active .top-back { animation: fly-up-top-back 0.6s forwards; } @keyframes fly-up-top-back { 100% { transform: rotateY(180deg) translateZ(100px) translateY(-130px); } } .top-left { transform: rotateY(-90deg) translateZ(100px); } .cube.active .top-left { animation: fly-up-top-left 0.6s forwards; } @keyframes fly-up-top-left { 100% { transform: rotateY(-90deg) translateZ(100px) translateY(-130px); } } .top-right { transform: rotateY(90deg) translateZ(100px); } .cube.active .top-right { animation: fly-up-top-right 0.6s forwards; } .........完整代码请登录后点击上方下载按钮下载查看
网友评论0