Created
April 30, 2015 03:07
-
-
Save jkfzero/811613678767b7f92ab1 to your computer and use it in GitHub Desktop.
自动适配,将web的100px设置为1rem
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
| window.onresize = r; | |
| function r(resizeNum){ | |
| var winW = window.innerWidth; | |
| document.getElementsByTagName("html")[0].style.fontSize=winW*0.15625+"px"; | |
| if(winW>window.screen.width&&resizeNum<=10){ | |
| setTimeout(function(){ | |
| r(++resizeNum) | |
| }, 100); | |
| } | |
| else{ | |
| document.getElementsByTagName("body")[0].style.opacity = 1; | |
| } | |
| }; | |
| setTimeout(function(){r(0)}, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment