当前位置: 移动技术网 > IT编程>开发语言>JavaScript > 手机端转换rem适应

手机端转换rem适应

2019年03月20日  | 移动技术网IT编程  | 我要评论

话不多说,请看代码:

 <script>
  (function() {
   var changerem = function() {
    document.getelementsbytagname('html')[0].style.fontsize = document.documentelement.clientwidth / 20 + 'px';
   };
   changerem();
   var t;
   window.addeventlistener('resize', function() {
    cleartimeout(t);
    t = settimeout(changerem, 300);
   }, false);
   window.addeventlistener('pageshow', function(e) {
    if (e.persisted) {
     cleartimeout(t);
     t = settimeout(changerem, 300);
    }
   }, false);
  }());
 </script>

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持移动技术网!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网