纯css实现卡片三维汽车颠簸行驶动画效果
代码语言:html
所属分类:动画
代码描述:纯css实现卡片三维汽车颠簸行驶动画效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body { background: #fff; height: 100vh; overflow: hidden; display: -webkit-box; display: flex; font-family: 'Anton', sans-serif; -webkit-box-pack: center; justify-content: center; -webkit-box-align: center; align-items: center; -webkit-perspective: 1000px; perspective: 1000px; } div { position: absolute; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; background: linear-gradient(45deg, #a95b58 0%, #db8d8a 100%); box-sizing: border-box; will-change: transform; } .window { background: rgba(0, 100, 255, 0.3); } #truck { -webkit-animation: drive 10000ms linear infinite; animation: drive 10000ms linear infinite; } #truck .body { width: 100px; -webkit-transform: translate(200px, -100px) translateZ(100px); transform: translate(200px, -100px) translateZ(100px); } #truck .shadow { width: 160px; height: 210px; background: #aaaaaa; -webkit-transform-origin: 50% 100%; transform-origin: 50% 100%; -webkit-transform: translate(-30px, -130px) translateZ(20px) rotateX(90deg); transform: translate(-30px, -130px) translateZ(20px) rotateX(90deg); -webkit-filter: blur(0px); filter: blur(0px); box-shadow: 0 0 35px 25px white inset; -webkit-backface-visibility: hidden; backface-visibility: hidden; } #truck .cockpit { -webkit-animation: bounce 600ms ease-out infinite alternate; animation: bounce 600ms ease-out infinite alternate; } #truck .cockpit .front { width: 100px; height: 50px; } #truck .cockpit .back { width: 100px; height: 75px; -webkit-transform: translate(0, -50px) translateZ(-50px); transform: translate(0, -50px) translateZ(-50px); } #truck .cockpit .top { width: 100px; height: 25px; -webkit-transform-origin: 50% 100%; transform-origin: 50% 100%; -webkit-transform: translate(0, -75px) translateZ(-25px) rotateX(90deg); transform: translate(0, -75px) translateZ(-25px) rotateX(90deg); } #truck .cockpit .bottom { width: 100px; height: 50px; -webkit-transform-origin: 50% 100%; transform-origin: 50% 100%; -webkit-transform: translate(0, -25px) rotateX(90deg); transform: translate(0, -25px) rotateX(90deg); } #truck .cockpit .left { width: 50px; height: 100px; -webkit-transform-origin: 0 0; transform-origin: 0 0; -webkit-transform: translate(100px, -50px) rotateY(90deg); transform: translate(100px, -50px) rotateY(90deg); -webkit-clip-path: polygon(0% 50%, 50% 50%, 50% 0%, 100% 0%, 100% 75%, 60% 75%, 40% 100%, 0% 100%); clip-path: polygon(0% 50%, 50% 50%, 50% 0%, 100% 0%, 100% 75%, 60% 75%, 40% 100%, 0% 100%); } #truck .cockpit .right { width: 50px; height: 100px; -webkit-transform-origin: 100% 0; transform-origin: 100% 0; -webkit-transform: translate(-50px, -50px) rotateY(-90deg); transform: translate(-50px, -50px) rotateY(-90deg); -webkit-clip-path: polygon(101% 50%, 50% 50%, 50% 0%, 0% 0%, 0% 75%, 40% 75%, 60% 100%, 101% 100%); clip-path: polygon(101% 50%, 50% 50%, 50% 0%, 0% 0%, 0% 75%, 40% 75%, 60% 100%, 101% 100%); } #truck .cockpit .left_headlight { width: 25px; height: 10px; background: #defeed; border-radius: 3px; -webkit-transform: translate(5px, 20px) translateZ(1px); transform: translate(5px, 20px) translateZ(1px); } #truck .cockpit .right_headlight { width: 25px; height: 10px; background: #defeed; border-radius: 3px; -webkit-transform: translate(70px, 20px) translateZ(1px); transform: translate(70px, 20px) translateZ(1px); } #truck .cockpit .left_window { width: 25px; height: 50px; -webkit-transform-origin: 0 0; transform-origin: 0 0; -webkit-transform: translate(100px, -50px) rotateY(90deg); transform: translate(100px, -50px) rotateY(90deg); -webkit-clip-path: polygon(0% 100%, 100% 0%, 100% 100%); clip-path: polygon(0% 100%, 100% 0%, 100% 100%); } #truck .cockpit .right_window { width: 25px; height: 50px; -webkit-transform-origin: 100% 0; transform-origin: 100% 0; -webkit-transform: translate(-25px, -50px) rotateY(-90deg); transform: translate(-25px, -50px) rotateY(-90deg); -webkit-clip-path: polygon(100% 100%, 0% 0%, 0% 100%); clip-path: polygon(100% 100%, 0% 0%, 0% 100%); } #truck .cockpit .front_window { width: 100px; height: 50px; -webkit-transform-origin: 50% 100%; transform-origin: 50% 100%; -webkit-transform: translate(0, -50px) rotateX(26deg) scaleY(1.12); transform: translate(0, -50px) rotateX(26deg) scaleY(1.12); } #truck .cockpit .front_window::before { content: ''; position: absolute; width: 5px; height: 100%; background: linear-gradient(45deg, #a95b58 0%, #db8d8a 100%); } #truck .cockpit .front_window::after { content: ''; position: absolute; right: 0; width: 5px; height: 100%; background: linear-gradient(45deg, #a95b58 0%, #db8d8a 100%); } #truck .cockpit .handle { width: 30px; height: 30px; border-radius: 100%; background: none; border: 5px solid #a95b58; -webkit-transform: translate(10px, -10px) translateZ(-10px) rotateX(-20deg); transform: translate(10px, -10px) translateZ(-10px) rotateX(-20deg); } #truck .cockpit .left_seat_back { width: 30px; height: 50px; background: dimgray; -webkit-transform-origin: 50% 100%; transform-origin: 50% 100%; -webkit-transform: translate(60px, -30px) translateZ(-40px) rotateX(10deg); transform: translate(60px, -30px) translateZ(-40px) rotateX(10deg); border-radius: 5px 5px 0 0; } #truck .cockpit .left_seat_bottom { width: 30px; height: 20px; background: dimgray; -webkit-transform-origin: 50% 100%; transform-origin: 50% 100%; -webkit-transform: translate(60px, 0px) translateZ(-20px) rotateX(90deg); transform: translate(60px, 0px) translateZ(-20px) rotateX(90deg); } #truck .cockpit .right_seat_back { width: 30px; height: 50px; background: dimgray; -webkit-transform-origin: 50% 100%; transform-origin: 50% 100.........完整代码请登录后点击上方下载按钮下载查看
网友评论0