[30일 챌린지 Day-16] Mouse Move Shadow

2022. 8. 11. 10:32·개발/html, css, js
728x90
반응형

1. 코드

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Mouse Shadow</title>
</head>
<body>

  <div class="hero">
    <h1 contenteditable>🔥WOAH!</h1>
  </div>

  <style>
  html {
    color: black;
    font-family: sans-serif;
  }

  body {
    margin: 0;
  }

  .hero {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: black;
  }

  h1 {
    text-shadow: 10px 10px 0 rgba(0,0,0,1);
    font-size: 100px;
  }
  </style>

<script>
</script>
</body>
</html>

2. 결과

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Mouse Shadow</title>
  </head>
  <body>
    <div class="hero">
      <h1 contenteditable>🔥WOAH!</h1>
    </div>

    <style>
      html {
        color: black;
        font-family: sans-serif;
      }

      body {
        margin: 0;
      }

      .hero {
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        color: black;
      }

      h1 {
        text-shadow: 10px 10px 0 rgb(0, 0, 0);
        font-size: 100px;
      }
    </style>

    <script>
      const h1 = document.querySelector("h1");
      window.onmousemove = function (e) {
        h1.style.textShadow = `
        ${e.clientY - h1.offsetTop - 67}px ${
          -e.clientX + h1.offsetLeft + 230
        }px 0 rgb(0,255,0),
        ${e.clientX - h1.offsetLeft - 230}px ${
          e.clientY - h1.offsetTop - 67
        }px 0 rgb(255,0,255),
        ${-e.clientX + h1.offsetLeft + 230}px ${
          e.clientY - h1.offsetTop - 67
        }px 0 rgb(0,255,255),
        ${-e.clientY + h1.offsetTop + 67}px ${
          e.clientX - h1.offsetLeft - 230
        }px 0 rgb(0,0,255)
        `;
      };
    </script>
  </body>
</html>

3. 리뷰

 

text-Shadow를 js로 불러올때의 형태만 알면 된다.

 

js로 불러올때 형식

h1.style.textShadow = " x  y  blur color" 

blur를 입력해주지 않으면 기본적으로 0이다.

728x90
반응형

'개발 > html, css, js' 카테고리의 다른 글

[JS] var, let, const 차이  (1) 2022.10.05
[30일 챌린지 Day-17] 관사 제외하고 정렬하기  (0) 2022.08.11
[30일 챌린지 Day-15] LocalStorage  (0) 2022.08.11
[30일 챌린지 Day-13] scroll event  (0) 2022.08.09
[30일 챌린지 Day-12] hidden key  (2) 2022.08.09
'개발/html, css, js' 카테고리의 다른 글
  • [JS] var, let, const 차이
  • [30일 챌린지 Day-17] 관사 제외하고 정렬하기
  • [30일 챌린지 Day-15] LocalStorage
  • [30일 챌린지 Day-13] scroll event
TeTedo.
TeTedo.
  • TeTedo.
    TeTedo 개발 일기
    TeTedo.
  • 전체
    오늘
    어제
    • 분류 전체보기 (319)
      • 개발 (274)
        • Article (4)
        • 정리 (21)
        • Spring Boot (17)
        • JPA (2)
        • JAVA (6)
        • Database (4)
        • 자료구조 (11)
        • 알고리즘 (32)
        • React (20)
        • Docker (10)
        • node.js (18)
        • Devops (11)
        • Linux (4)
        • TypeScript (3)
        • Go (10)
        • HyperLedger (4)
        • BlockChain (43)
        • html, css, js (48)
        • CS (3)
        • AWS (3)
      • 모아두고 나중에 쓰기 (3)
      • 팀프로젝트 (18)
        • SNS(키보드워리어) (9)
        • close_sea (9)
      • 개인프로젝트 (1)
        • Around Flavor (1)
        • CHAM (13)
        • ethFruitShop (5)
      • 독서 (0)
        • 스프링부트와 AWS로 혼자 구현하는 웹 서비스 (0)
  • 블로그 메뉴

    • 홈
    • 개발일기
    • CS
    • 실습
    • 코딩테스트
    • 웹
    • Go
    • node.js
    • 팀플
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    go
    프로그래머스
    go언어
    erc20
    하이퍼레저
    html
    30일 챌린지
    컨테이너
    도커
    node
    30일챌린지
    nodejs
    ERC721
    CSS
    node.js
    js
    React
    mysql
    명령어
    블록체인
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.1
TeTedo.
[30일 챌린지 Day-16] Mouse Move Shadow
상단으로

티스토리툴바