Created
July 2, 2024 06:57
-
-
Save gogones/2c511209a61fa549a1f75896b94dc449 to your computer and use it in GitHub Desktop.
Get value vw/vh from px given relative to screen define
This file contains 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
export const pxToVw = (px: number, windowWidth?: number) => | |
`${(px / (windowWidth ?? window.innerWidth)) * 100}vw`; | |
export const pxToVh = (px: number, windowHeight?: number) => | |
`${(px / (windowHeight ?? window.innerHeight)) * 100}vh`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment