css实现3d城市效果
代码语言:html
所属分类:三维
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>3D City Animation Pure CSS</title> <style> /* Variables */ :root { --bg: #DBDBDB; --gray: #393F4D; --gray-l: #f5f5f5; --cyan: #B6E4E6; --green: #51E5FF; --yellow: #FDE74C; } /* Reset */ *, *::after, *::before { margin: 0; padding: 0; box-sizing: border-box; text-rendering: optimizeLegibility; user-select: none; } /* Tag */ html { font-family: sans-serif; } body { display: flex; justify-content: center; align-items: center; width: 100%; min-height: 100vh; background: var(--bg); } main { min-width: 800px; height: 300px; position: relative; transform-style: preserve-3d; animation: rotate-container 10s infinite ease-in-out alternate; } /* Components */ .way { position: absolute; top: 0; width: 350px; height: 350px; background: var(--gray); border: 50px solid var(--gray-l); transform: rotateX(90deg); transform-style: preserve-3d; border-radius: 15px; box-shadow: 2px 2px 100px 0px rgba(0,0,0,0.1); } .way-l { left: 0; } .way-r { right: 0; display: flex; } .ad { position: absolute; top: 150px; left: 80px; transform: rotateY(-20deg); font-size: 10px; padding: 2px 5px; letter-spacing: 2px; border-radius: 2px; color: white; background: var(--gray); border: 1px solid white; animation: ad-sale 1s linear infinite 1s; } .txt { position: absolute; top: 50px; left: calc(50% - 75px); width: 150px; font-size: 20px; padding: 3px 5px; letter-spacing: 2px; text-align: center; color: white; background: var(--gray); border-radius: 4px; box-shadow: 3px 3px 100px 3px rgba(0,0,0,0.2); } .way-r .cube { height: 300px; width: 100px; transform: rotateX(90deg) rotateY(180deg) rotateZ(180deg) translateY(-80px) translateX(20px) translateZ(-10px) scale(.5);; } .bridge { width: 50px; height: 100px; background: var(--green); position: absolute; } .bridge-l { transform: rotateX(90deg) rotateZ(90deg) translateY(-275px) translateZ(-125px) translateX(150px); animation: move-bridge-l 15s linear infinite; border-top: 5px solid var(--gray); border-bottom: 5px solid var(--gray); } .bridge-r { transform: rotateX(90deg) rotateZ(90deg) translateY(-475px) translateZ(-125px) translateX(150px); animation: move-bridge-r 15s linear infinite; border-top: 5px solid var(--gray); border-bottom: 5px solid var(--gray); } .cube { height: 300px; width: 100px; position: relative; z-index: 300; transform-style: preserve-3d; transform: rotateX(90deg) rotateY(180deg) rotateZ(180deg) translateY(-120px) translateX(80px) translateZ(-10px) scale(.75);; } .cube__face { width: 100%; height: 100%; position: absolute; backface-visibility: hidden; display: flex; justify-content: center; align-items: flex-start; flex-direction: row; flex-wrap: wrap; padding-top: 5px; padding-bottom: 20px; background: white; border: 2px solid white; border-bottom: 2px solid var(--gray); } .cube__face:hover { border: 2px solid var(--green); cursor: pointer; } .cube__window { height: 20px; width: 100px; margin: 5px 7px 0px; border-radius: 3px; background: var(--gray-l); } .cube__window-light-1 { animation: window-light 4.8s linear infinite .25s; } .cube__window-light-2 { animation: window-light 3.3s linear infinite; } .cube__window-light-3 { animation: window-light 4.2s linear infinite 2s; } .cube__window-light-4 { animation: window-light 3s linear infinite; } .cube__window-light-5 { animation: window-light 2.5s linear infinite 1s; } .cube__door { height: 40px; width: 60%; background: var(--gray); border-top-left-radius: 2px; border-top-right-radius: 2px; align-self: flex-end; .........完整代码请登录后点击上方下载按钮下载查看
网友评论0