我用了rem 与 vw属性 都不好用 rem 根本不行 vw屏幕大小调整到120%以上字就开始变大了 是我使用不正确吗
vw是根据实际屏幕大小的百分比走的
通常我们都是用rem
第一步,定义好对应屏幕大小的font-size,因为你的实际大小等于font-size*rem
https://www.cnblogs.com/500m/p/12682964.html
你也可以利用@media自己定义font-size
然后你再写对应的页面的大小就好了
可以使用flexble配合rem实现移动端自适应
https://blog.csdn.net/weixin_39411655/article/details/113792069
window.onload = function () {
var setRem = function () {
// UI设计稿的宽度
var uiWidth = 750;
// 移动端屏幕宽度
var winWidth = document.documentElement.clientWidth;
// 比率
var rate = winWidth / uiWidth;
// 设置html元素的字体大小
document.documentElement.style.fontSize = rate * 20 + "px"
};
setRem();
window.onresize = function () {
setRem();
}
}