Parallax эффект прокрутки на CSS3 и SVG
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
body { background: rgba(255,255,255,0.9); margin: 0; } .parallax { position: relative; -webkit-perspective: 1px; perspective: 1px; -webkit-perspective-origin: 50% 100%; perspective-origin: 50% 100%; width: 100vw; height: 100vh; overflow-x: hidden; overflow-y: auto; } .mountains { position: relative; width: 100vw; height: 60vh; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; z-index: -1; } .peak,.logo { position: absolute; top: 0; right: 0; bottom: 0; left: 0; -webkit-transform-origin: 50% 100%; transform-origin: 50% 100%; } .peak.p0,.logo.p0 { -webkit-transform: translateZ(-40px) scale(41); transform: translateZ(-40px) scale(41); } .peak.p1,.logo.p1 { -webkit-transform: translateZ(-25px) scale(26); transform: translateZ(-25px) scale(26); } .peak.p2,.logo.p2 { -webkit-transform: translateZ(-15px) scale(16); transform: translateZ(-15px) scale(16); } .peak.p3,.logo.p3 { -webkit-transform: translateZ(-8px) scale(9); transform: translateZ(-8px) scale(9); } .peak.p4,.logo.p4 { -webkit-transform: translateZ(-5px) scale(6); transform: translateZ(-5px) scale(6); } .peak.p5,.logo.p5 { -webkit-transform: translateZ(-4px) scale(5); transform: translateZ(-4px) scale(5); } .peak.p6,.logo.p6 { -webkit-transform: translateZ(-3px) scale(4); transform: translateZ(-3px) scale(4); } .peak.p7,.logo.p7 { -webkit-transform: translateZ(-2px) scale(3); transform: translateZ(-2px) scale(3); } .peak.p8,.logo.p8 { -webkit-transform: translateZ(-1px) scale(2); transform: translateZ(-1px) scale(2); } .peak.p9,.logo.p9 { -webkit-transform: translateZ(-0.5px) scale(1.5); transform: translateZ(-0.5px) scale(1.5); } .peak img,.logo img { position: absolute; width: 110%; height: auto; left: -5%; bottom: -5%; } .overlay { position: absolute; width: 100vw; height: 100vh; left: 0; top: 0; background: -webkit-linear-gradient(top,#7168b5 0%,#418eab 50%,#83b6c9 100%); background: linear-gradient(top,#7168b5 0%,#418eab 50%,#83b6c9 100%); opacity: .7; } .multiply { opacity: 1; mix-blend-mode: overlay; } .logo { -webkit-transform: translateZ(-2px) scale(3); transform: translateZ(-2px) scale(3); } .logo h1 { font-size: 10rem; color: #333; position: absolute; width: 100vw; bottom: 25vw; padding: 0; text-shadow: 0 50px 20px rgba(0,0,0,0.3); } main { position: relative; width: 100vw; padding: 40px; background: #83b6c9; z-index: 2; } article { max-width: 800px; margin: 0 auto; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
<div class="parallax"> <div class="mountains"> <div class="peak p0"><img alt="mountain peak" src="/img/mountain-0.svg"></div> <div class="peak p1"><img alt="mountain peak" src="/img/mountain-1.svg"></div> <div class="peak p2"><img alt="mountain peak" src="/img/mountain-2.svg"></div> <div class="peak p3"><img alt="mountain peak" src="/img/mountain-3.svg"></div> <div class="peak p4"><img alt="mountain peak" src="/img/mountain-4.svg"></div> <div class="peak p5"><img alt="mountain peak" src="/img/mountain-5.svg"></div> <div class="peak p6"><img alt="mountain peak" src="/img/mountain-6.svg"></div> <div class="peak p7"><img alt="mountain peak" src="/img/mountain-7.svg"></div> <div class="peak p8"><img alt="mountain peak" src="/img/mountain-8.svg"></div> <div class="peak p9"><img alt="mountain peak" src="/img/mountain-9.svg"></div> <div class="peak"> <div class="overlay"></div> </div> <div class="logo"> <center><h1>IMAPO</h1></center> </div> </div> <main> <article title="Lorem"> <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> </article> </main> </div> <script> // Safari Sniffing for the purpose of using mix-blend-mode // Not default in chrome / funky in FF (function() { function isSafari() { var userAgent = navigator.userAgent; return (/Safari/gi).test(userAgent) && !(/Chrome/gi).test(userAgent); } if(isSafari()) { var overlay = document.querySelector('.overlay'); overlay.classList.add('multiply'); } })(); </script> |