这是研究了淘宝和拉钩以及网易的兼容全局样式后,提取的兼容样式,经过实战可用
css全局样式
@media screen and (max-width:321px){
body,html{font-size:15px}
}
@media screen and (min-width:321px) and (max-width:400px){
body,html{font-size:16px}
}
@media screen and (min-width:400px){
body,html{font-size:18px}
}
js全局样式
1.当设计稿是750px的时候,设置值为3.75时:
1px=0.01rem;
全局用的时rem单位
var deviceWidth = document.documentElement.clientWidth;
if(deviceWidth > 750) deviceWidth = 750;
document.documentElement.style.fontSize = deviceWidth / 3.75+ 'px';
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有