Animated Rainbow Nyan Cat
본문 바로가기
Effect/mouse

마우스 이펙트 03

by 이유나1 2022. 9. 22.
728x90
반응형

마우스 이펙트 03 - 조명 효과


script 코드

 const cursor = document.querySelector('.mouse__cursor')

    //   const circleW = cursor.offsetWidth //200
    //   const circleH = cursor.offsetHeight //200
    //   const circle2 = cursor.clientWidth //190 : 보더값 제외

    const circle = cursor.getBoundingClientRect()
    console.log(circle)
    //   const DOMRect = {
    //     x: 0,
    //     y: 0,
    //     bottom: 200,
    //     height: 200,
    //     left: 0,
    //     right: 200,
    //     top: 0,
    //     width: 200
    //   }
    window.addEventListener('mousemove', (e) => {
      gsap.to(cursor, {
        duration: 0.5,
        left: e.pageX - circle.width / 2,
        top: e.pageY - circle.height / 2,
      })
    })

html

코드 보기

 

<section id="mouseType">
  <div class="mouse__cursor"></div>
  <div class="mouse__cursor2"></div>
  <div class="mouse__wrap">
    <p> The <span class="style1">future</span>
      <span class="style2">depends</span> on What we do in the <span class="style3">present.</span>
    </p>
    <p>
      <span class="style4">미래</span> 는 현재 <span class="style5">우리가</span> 무엇을 <span class="style6">하는가에</span> 달려있다.
    </p>
  </div>
</section>

css

코드 보기

 

  /* mouseType */
  .mouse__wrap {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    overflow: hidden;
    flex-direction: column;
    cursor: none;
  }

  .mouse__wrap p {
    font-size: 2vw;
    line-height: 2;
    font-weight: 300;
  }

  .mouse__wrap p:last-child {
    font-size: 3vw;
    font-weight: 300;
  }

  .mouse__wrap p span {
    border-bottom: 0.15vw dashed orange;
    color: orange;
  }

  @media (max-width: 800px) {
    .mouse__wrap p {
      padding: 0 20px;
      font-size: 24px;
      line-height: 1.5;
      text-align: center;
      margin-bottom: 10px;
    }

    .mouse__wrap p:last-child {
      font-size: 40px;
      line-height: 1.5;
      text-align: center;
      word-break: keep-all;
    }
  }

  .mouse__cursor {
    position: absolute;
    left: 0;
    top: 0;
    width: 200px;
    height: 200px;
    z-index: -1;
    border-radius: 50%;
    background-image: url(../assets/img3/effect_bg03@2x-min.jpg);
    background-size: cover;
    background-position: center center;
    background-attachment: fixed;
    border: 5px solid #fff;
  }
728x90

'Effect > mouse' 카테고리의 다른 글

마우스 이펙트 05  (1) 2022.09.28
마우스 이펙트 04  (4) 2022.09.22
마우스 이펙트 02  (2) 2022.09.19
마우스 이펙트 01  (2) 2022.09.05

댓글


/
/
/

CSS
광고준비중입니다.