[Day16] CSS Text Shadow Mouse Move Effec

[Day16] CSS Text Shadow Mouse Move Effect

滑鼠移动 物件更换影子位置

需要用到的技巧与练习目标

  1. mousemove
  2. Math.round
  3. offsetX offsetY
const hero = document.querySelector('.hero');

const text = hero.querySelector('h1');

function shadow(e){
const { offsetWidth:width, offsetHeight:height}= hero;
let {offsetX:x offsetY:y} = e;

if(this !== e.target){
x = x + e.target.offsetLeft;
y = y + e.target.offsetTop;
 
}

const xWalk = Math.round((x / width*walk) - (walk /2));

const yWalk =Math.round( (y / Height*walk) - (walk /2));

text.style.textShadow=`${xWalk}px ${ywalk}px 0 red`

}

hero.addEventListener('mosemove',shadow)

<<:  如何衡量万事万物 (10) 人的判断

>>:  [Day 16]新试剂服英战士(後端篇)

[13th][Day9] Pointer-1

那麽 ... 要如何改动 House.price 的『值』呢? package main impor...

MITRE Engenuity ATT&CK Evaluations 测试报告

才刚提到趋势科技去年在 MITRE Engenuity 的 ATT&CK Evaluatio...

[铁人赛 Day11] React 原始码的初见面 ——官方 codebase 指南

前言 为了更近一步理解平常使用的 useState, useEffect, memo...等机制的运...

13 - Logs - 挖掘系统内部发生的状况 (1/4) - Logs 与 Filebeat 的基本介绍

Logs - 挖掘系统内部发生的状况 系列文章 (1/4) - Logs 与 Filebeat 的基...

DAY 17 制作 Nav Bar - Header

整个画面中最先看到的是 header 的 nav bar ,就让我们从这里开始刻吧! 首先在 App...