Java教程

手机端 等比例自适应

本文主要是介绍手机端 等比例自适应,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

<!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>

这篇关于手机端 等比例自适应的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!