rem與less適配

<!doctype html>
<html lang="en" >
<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>rem與less適配</title>
<link rel="stylesheet" href="./css/app.css">
</head>
<body>
<div id="box">

</div>
<script>
document.documentElement.style.fontSize = document.documentElement.clientWidth / 10 + 'px'
// 最終
window.onresize = function(){
// 設置新的 font-size
document.documentElement.style.fontSize = document.documentElement.clientWidth / 10 + 'px'
}


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


*{  margin:0;  padding:0;}@fontSize: 375 / 10rem;#box{  width:335 / @fontSize;  height:144/ @fontSize;  margin:.50/ @fontSize auto;  background:#999;}
相關文章
相關標籤/搜索