前端的自适应

方法一:适合pc端用rem单位
<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1,maximum-scale=1,user-scalable=no">
<style>
html,body{
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
#app{
width: 25.6rem;
height: 100%;
overflow: auto;
margin: 0 auto;
}
</style>
<script>
document.addEventListener("DOMContentLoaded",function(){
_flexable();
});

window.onresize = function(){
_flexable();
}
function _flexable(){
var width = document.documentElement.clientWidth;
document.getElementsByTagName("html")[0].style.fontSize=(width/2560)*100+"px";
}
//if (process.env.NODE_ENV !== 'development') window.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')图片路径
</script>
方法二:配置rem单位
// px2Rem  把px ==>rem  150px  1rem = 75px  2rem
@function p($px,$base:75){
@return ($px/$base) * 1rem;
}
height: calc(88rem / 75);

转载于:https://www.cnblogs.com/flavorhome/p/9412838.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值