- <script>
- (function () {
- // 在标准 375px 适配下,100px = 1rem;
- var basefontsize = 100;
- var basewidth = 375;
- var set = function () {
- var clientwidth = document.documentelement.clientwidth || window.innerwidth;
- var rem = 100;
- if (clientwidth != basewidth) {
- rem = math.floor(clientwidth / basewidth * basefontsize);
- }
- document.queryselector('html').style.fontsize = rem + 'px';
- }
- set();
- window.addeventlistener('resize', set);
- }());
- </script>