본문 바로가기
Js

scroll, clip-path

by 영감은어디에 2024. 7. 4.


<div class="wrap">
    <div class="sbox" id="s1"></div>
    <div class="sbox" id="s2"></div>
</div>
<h1 class="text">Scroll animation</h1>
let s1 = document.getElementById('s1');
let s2 = document.getElementById('s2');
window.addEventListener("scroll", function(){
   s1.style.left = window.scrollY +'px';
   s2.style.left = - window.scrollY + 'px';
})
.wrap{position: fixed;top: 0; left: 0; width: 100%; height: 100vh; z-index: 100;}
.wrap .sbox{position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: blueviolet;}
.wrap .sbox#s1{ background-color: yellow;clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);}
.wrap .sbox#s2{background-color: rgb(164, 218, 229);clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);}

'Js' 카테고리의 다른 글

gsap toArray, forEach  (0) 2024.07.05
gsap2  (0) 2024.07.05
gsap 1  (0) 2024.07.05
scroll  (0) 2024.07.04
sort, filter  (0) 2024.07.01
ajax  (0) 2024.07.01
select, append, forEach  (0) 2024.07.01
array  (0) 2024.07.01