If you want to die, you'll live. If you want to live, you'll die.
죽고자 하면 살 것이요, 살고자 하면 죽을 것이다.
If you want to die, you'll live. If you want to live, you'll die.
죽고자 하면 살 것이요, 살고자 하면 죽을 것이다.
마우스 이펙트 - 따라다니기
<main>
<section id="mouseType01">
<div class="cursor"></div>
<div class="mouse__wrap">
<p>If you want to die, you'll <span class="style1">live</span>. If you want to live, you'll <span class="style2">die</span>.</p>
<p><span class="style3">죽고자</span> 하면 <span class="style4">살</span> 것이요, <span class="style5">살고자</span> 하면 <span class="style6">죽을</span> 것이다.</p>
</div>
</section>
</main>
.mouse__wrap {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
color: #fff;
width: 100%;
height: 100vh;
overflow: hidden;
cursor: none;
}
.mouse__wrap p {
font-size: 2.5vw;
line-height: 2;
font-weight: 300;
}
.mouse__wrap p:last-child {
font-size: 3vw;
font-weight: 400;
}
.mouse__wrap p span {
border-bottom: 0.15vw dashed #fff;
}
.cursor {
position: absolute;
left: 0; top: 0;
width: 50px;
height: 50px;
border-radius: 50%;
border: 3px solid #fff;
background-color: rgba(255,255,255,0.1);
user-select: none;
pointer-events: none;
transition:
background-color .2s,
order-color .2s,
transform .6s,
border-radius .2s,
skewX 1s;
}
.cursor.style1 {
background-color: rgba(255,165,0,0.4);
border-color: orange;
}
.cursor.style2 {
background-color: rgba(140,0,255,0.4);
border-color: rgb(140, 0, 255);
transform: rotate(720deg) scale(2);
}
.cursor.style3 {
background-color: rgba(0, 47, 255, 0.4);
border-color: rgb(0, 47, 255);
transform: scale(1.5) rotate(45deg);
border-radius: 10px;
}
.cursor.style4 {
background-color: rgba(121, 235, 197, 0.4);
border-color: rgb(121, 235, 197);
transform: scale(10) rotateY(360deg);
}
.cursor.style5 {
background-color: rgba(255, 0, 85, 0.4);
border-color: rgb(255, 0, 85);
transform: rotateY(720deg) scale(0.1);
}
.cursor.style6 {
background-color: rgba(219, 235, 0, 0.4);
border-color: rgb(219, 235, 0);
transform: scale(3) skewX(180deg);
}
const style = document.querySelectorAll(".mouse__wrap span");
const cursor = document.querySelector(".cursor");
//마우스 움직이기
window.addEventListener("mousemove", e => {
let x = e.clientX-25 + "px";
let y = e.clientY-25 + "px";
cursor.style.cssText = `left: ${x}; top: ${y};`;
});
//마우스 효과
style.forEach((e, i) => {
let attr = e.getAttribute("class");
e.addEventListener("mouseover", () => {
cursor.classList.add(attr);
});
e.addEventListener("mouseout", () => {
cursor.classList.remove(attr);
});
});