您的位置:首页 > 移动开发

REM布局计算,移动端,pc端有兼容性)

2016-11-08 13:38 363 查看

rem布局计算(移动端,pc端有兼容性)

<!DOCTYPE html>
<html>
<head lang="en">
<script>
function rootREM() {
var W = document.documentElement.clientWidth;
W = (W <= 640) ? W : 640;
document.documentElement.style.fontSize = W / 10 + 'px';
document.body.style.fontSize = W / 20 + 'px';
}
window.onresize = function () {
rootREM()
};
</script>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
</head>
<body onload="rootREM()">

<div style="max-width: 640px;">
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!
<br/>你好,世界!

</div>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: