UNPKG

moving-shadow

Version:

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

118 lines (104 loc) 2.15 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:wght@800&display=swap" rel="stylesheet"> <!-- <script src="../movingShadow.js"></script> --> <script src="https://unpkg.com/moving-shadow"></script> <title>Perspective | Moving Shadow</title> </head> <body> <div class="container"> <h1>vinyl bar</h1> <div class="in-out"> <div class="button"> <h4>out</h4> </div> <div class="button"> <h4>in</h4> </div> </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: #b89714; color: #e6e1cb; font-size: 4rem; } @media (max-width: 600px) { .container { font-size: 2rem; } } h1, h4 { margin: 10px; text-align: center; max-width: 80%; } h1 { margin-bottom: 20vh; } .in-out { display: flex; justify-content: space-around; align-items: center; width: 80%; } .button { padding: 20px; border-radius: 25px; background-color: #e6e1cb; /* transition: 0.35s; */ } .button:active { box-shadow: none; /* transition: 0.35s; */ } .button h4 { color: #b89714; opacity: 1; transition: color 0.35s; } .button:hover h4 { color: #665200; transition: color 0.35s; cursor: pointer; } </style> <script> const fixedColor = "#665200"; const fixedColor2 = "#222"; const settings = [ { selector: "h1", // targets class or id angle: 80, shadowType: "perspective", color: fixedColor, // shadow-color color2: `${fixedColor}22`, // shadow-color }, { selector: ".button", // targets class or id shadowType: "perspective", angle: 80, color: fixedColor, // shadow-color altColor: `${fixedColor}22`, // shadow-color }, ] movingShadow(settings); </script>