Created
March 15, 2018 15:24
-
-
Save vldvel/b6d938479624358f9e565f131b8c3c48 to your computer and use it in GitHub Desktop.
Box shadows in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const offsetX = 10; // horizontal distance - any number | |
| const offsetY = 10; // vertical distance - any number | |
| const blurRadius = 20; // shadow blur - positive number - default = 0 | |
| const spreadRadius = 40; // shadow size - any number - deafult = 0 | |
| const color = 'rgba(255, 255, 199, 0.7)'; // color - rgb/rgba/hsl/hsla | |
| // basic options | |
| element0.style.boxShadow = `${offsetX}px ${offsetY}px ${color}`; | |
| // full options | |
| element1.style.boxShadow = `${offsetX}px ${offsetY}px ${blurRadius}px ${spreadRadius}px ${color}`; | |
| // multiple shadows | |
| element2.style.boxShadow = `${offsetX}px ${offsetY}px ${color}, -${offsetX}px -${offsetY}px ${blurRadius}px ${spreadRadius}px ${color}`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment