码迷,mamicode.com
首页 > 其他好文 > 详细

页面自适应

时间:2018-08-17 11:24:41      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:get   func   font   ada   bsp   适应   window   name   code   

 1 // 自适应
 2 function autoScreen(){
 3     var font_size = 40;
 4     var col_num = 640 / font_size;
 5     var adapterSize = window.innerWidth / col_num;
 6     var htmlElement = document.getElementsByTagName("html")[0];
 7     htmlElement.style.fontSize = ‘‘ + adapterSize + ‘px‘;
 8     
 9     window.onresize=function (){
10         adapterSize = window.innerWidth / col_num;
11         htmlElement.style.fontSize = ‘‘ + adapterSize + ‘px‘;
12     }
13 };
14 autoScreen();

 

页面自适应

标签:get   func   font   ada   bsp   适应   window   name   code   

原文地址:https://www.cnblogs.com/muou2125/p/9491896.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!