首页 > 移动平台 > 详细

移动端px转化为rem

时间:2020-01-07 16:25:24      阅读:85      评论:0      收藏:0      [点我收藏+]

此知识点是在做APP是所用的,项目所用技术(ionic5/angular8),仅供参考!

getRem(pWidth): void {
 const htmlRoot = document.getElementsByTagName(‘html‘)[0];
 const oWidth = document.body.clientWidth || document.documentElement.clientWidth;
 htmlRoot.style.fontSize = oWidth / pWidth * 100 + ‘px‘;
}
pWidth:代表设计稿的宽度
100px=1rem

移动端px转化为rem

原文:https://www.cnblogs.com/happybread/p/12161738.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!