convert 25 to px javascript

Solutions on MaxInterview for convert 25 to px javascript by the best coders in the world

showing results for - "convert 25 to px javascript"
Lena
26 Jan 2019
1// convert px to %
2var pixels = 100; // px
3var screenWidth = window.screen.width; // total px across width
4var percentage = ( screenWidth - pixels ) / screenWidth ; // 0.92%
5
6// convert % to px
7var percentage = 5; // % 
8var screenWidth = window.screen.width; // total px across width
9var pixels = Math.round(( percentage/100 ) * screenWidth) ; // 90px