tnnyang

目前,有了css3的rem,给我们的移动端开发带来了前所未有的改变,使得我们的开发更容易,更易兼容很多设备,但这个不在本文讨论的重点中,本文重点说说如何使用js来实时改变网页文字的大小。
代码:

<script>
        /* 长宽占位 rem算法, 根据root的rem来计算各元素相对rem, 默认html 320/20 = 16px */
        function placeholderPic(){
            var w = document.documentElement.offsetWidth;
            document.documentElement.style.fontSize=w/20+\'px\';
        }
        placeholderPic();
        window.onresize=function(){
            placeholderPic();
        }
    </script>

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-11-27
  • 2021-06-26
  • 2022-01-07
  • 2021-11-27
相关资源
相似解决方案