首页 > 其他 > 详细

rem 比例值适配

时间:2020-10-01 23:43:36      阅读:45      评论:0      收藏:0      [点我收藏+]
<!doctype html>
<html lang="en" style="font-size: 37.5px;">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
margin:0;
padding:0;
}
#box{
width:4.24rem;
height:2.373rem;
margin-left:.56rem;
margin-top: 5.333rem;
background:#886;
}
</style>
</head>
<body>
<div id="box">

</div>
<script>

// 获取布局视口宽度
// var width = document.documentElement.clientWidth;
// var fontSize = width / 10;
// // 设置新的 font-size
// document.documentElement.style.fontSize = fontSize + ‘px‘
// 最终
window.onresize = function(){
// 设置新的 font-size
document.documentElement.style.fontSize = document.documentElement.clientWidth / 10 + ‘px‘
}


</script>
</body>
</html>

rem 比例值适配

原文:https://www.cnblogs.com/eric-share/p/13759259.html

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