视口
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" id="viewport" />
<style type="text/css">
*{
margin:0px;
padding: 0px;
}
div{
width: 80%;
height: 300px;
background: pink;
margin: 50px auto;
max-width: 1000px;
min-width: 200px;
}
p:first-child{
width: 50%;
height: 200px;
background: green;
float: left;
border: 2px solid red;
box-sizing:border-box;
}
p:last-child{
width: 50%;
height: 200px;
background: blue;
float: left;
border: 2px solid red;
box-sizing:border-box;
}
</style>
<body>
<h1 id="shuchu"></h1>
<script type="text/javascript">
xianshi();
window.onresize=xianshi;
function xianshi(){
var my= document.getElementById("shuchu");
my.innerHTML = document.documentElement.clientWidth;
}
</script>
<div>
<p></p>
<p></p>
</div>
</body>
</html>
加了视口
没加视口