rem 適配屏幕大小

1 window.onresize=function(){
2     var html=document.getElementsByTagName("html")[0];
3     var width=window.innerWidth; // 獲取窗口的文檔顯示區的寬度
4     var font_Size=16/1920*width; // 設計稿以1920爲準,在1920的設計稿中:16px = 1rem
5     html.style.fontSize=font_Size+"px";
6 };
相關文章
相關標籤/搜索