UNPKG

moving-shadow

Version:

A JavaScript module, which creates a responsive text shadow based on mouse position (desktop) or device orientation (mobile)

70 lines (62 loc) 1.49 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link href="https://fonts.googleapis.com/css2?family=Pacifico&display=swap" rel="stylesheet"> <!-- <script src="../movingShadow.js"></script> --> <script src="https://unpkg.com/moving-shadow"></script> <title>Perspective Shadow | Moving Shadow</title> </head> <body> <div class="container"> <h1>Well that's just like, <br>your opinion, man.</h1> </div> </body> </html> <style> html, body { margin: 0; overflow-x: hidden; overflow-y: hidden; height: 100vh; } .container { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; background-color: #f4cca4; color: #ec1313; font-family: 'Pacifico', cursive; font-size: 2.6rem; } @media (max-width: 600px) { .container { font-size: 1.5rem; } } h1, h3 { margin: 30px auto; text-align: center; max-width: 80%; } p { font-size: 22px; text-align: right; color: #b3cccc; } </style> <script> const settings = { selector: "h1, h3", // targets class or id shadowType: "perspective-shadow", // "shadow", "dropShadow", "perspective" angle: 60, // Sets height of light source. Should be > 10 && < 100. Default 20. diffusion: 0, // blur-radius color: "white", // shadow-color altColor: "#eeb377", } movingShadow(settings); </script>