UNPKG

moving-shadow

Version:

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

101 lines (89 loc) 1.8 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=Montserrat:display=swap" rel="stylesheet"> <!-- <script src="../movingShadow.js"></script> --> <script src="https://unpkg.com/moving-shadow"></script> <title>Shadow Example | Moving Shadow</title> </head> <body> <div class="container"> <h1>wapor vave</h1> <div class="in-out"> <button>exit</button> <button>enter</button> </div> </div> </body> </html> <style> html, body { margin: 0; overflow-x: hidden; overflow-y: hidden; height: 100vh; font-family: 'Montserrat', sans-serif; } .container { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; background-color: #222; color: #222; font-size: 4rem; } @media (max-width: 600px) { .container { font-size: 2rem; } } h1, h4 { margin: 10px auto; text-align: center; max-width: 80%; } h1 { margin-bottom: 20vh; } .in-out { display: flex; justify-content: space-around; align-items: center; width: 60%; } @min(width: 768px) { .in-out { width: 30%; } } button { background-color: #222; color: #44f; transition: color .35s; border: none; border-radius: 10px; padding: 12px; font-size: 1.2rem; } button:hover { color: #f2c; transition: color .35s; } </style> <script> const settings = { selector: "h1, button", // targets class or id shadowType: "perspective-shadow", angle: 80, color: "#f22", // shadow altColor: "#0003", // shadow shineColor: "#44f", fixedShadow: `0px 0px 10px #44fc` } movingShadow(settings); </script>