其他分享
首页 > 其他分享> > 手机端 等比例自适应

手机端 等比例自适应

作者:互联网

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>设计图为 320 / 568 比例</title>
<script src="./jQuery.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
body,
html {
padding: 0;
margin: 0;
}

#outer {
position: absolute;
left: 0;
overflow: hidden;
transform-origin: left top;
z-index: 999;
}
</style>
</head>
<body style="background-color: #000;">
<div id="outer">
<div style="padding: 10px;color:#fff;font-size:20px;;">
这是阿斯蒂芬阿斯顿发
<div style="margin-left:20px;">asdf asdf</div>
<div style="margin-left:40px;">asdf asdf</div>
<div style="margin-left:60px;">asdf asdf</div>
<div style="margin-left:80px;">asdf asdf</div>
<div style="margin-left:100px;">asdf asdf</div>
<div style="margin-left:120px;">asdf asdf</div>
<div style="margin-left:140px;">asdf asdf</div>
<div style="margin-left:160px;">asdf asdf</div>
<div style="margin-left:180px;">asdf asdf</div>
<div style="margin-left:200px;">asdf asdf</div>


<div style="margin-left:200px;">asdf asdf</div>
<div style="margin-left:180px;">asdf asdf</div>

<div style="margin-left:160px;">asdf asdf</div>
<div style="margin-left:140px;">asdf asdf</div>
<div style="margin-left:120px;">asdf asdf</div>
<div style="margin-left:100px;">asdf asdf</div>
<div style="margin-left:80px;">asdf asdf</div>
<div style="margin-left:60px;">asdf asdf</div>
<div style="margin-left:40px;">asdf asdf</div>
<div style="margin-left:20px;">asdf asdf</div>
这是阿斯蒂芬阿斯顿发
</div>
</div>

<script type="text/javascript">
const screenWidth = window.screen.width;
const screenHeight = window.screen.height;
$("#outer").css({
'transform': 'scale(' + (screenWidth / 320) + ')'
})
</script>
</body>
</html>

标签:outer,screen,transform,适应,320,比例,手机,screenWidth,asdf
来源: https://www.cnblogs.com/mrt-yyy/p/15738281.html