盒子模型可以以前总结过:http://taobao.fm/archives/986

今天写的这个,不常用;获取显示器的宽和高;

 

代码很简单;主要是用到:screen.width和screen.height

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
#div1{
width: 800px;
height: 200px;
line-height: 200px;
text-align: center;
background:orange;
}
.div1-class{
width: 800px;
height: 200px;
background:#003300;
color: #fff;;
}
</style>
</head>
<body>
<div id="div1"></div>
<div class="div1-class">
获取显示器的宽度和告诉代码用的是:
<p>var oDiv=document.getElementById("div1");</p>
<p>oDiv.innerHTML='您的显示器分辨率为: ' + screen.width + '*' + screen.height + ' 像素'</p>
<p>相关的知识点参考这个链接:http://taobao.fm/archives/986</p>
</div>
</body>
</html>
<script>
var oDiv=document.getElementById("div1");
oDiv.innerHTML='您的显示器分辨率为: ' + screen.width + '*' + screen.height + ' 像素';
</script>