DOCTYPE为Strict<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
<head>
<title>测试</title>
<meta http-equiv="content-type" content="text/html; charset=gbk" />
<meta http-equiv="content-style-type" content="text/cee" />
<meta http-equiv="content-script-type" content="text/javascript" />
<script type="text/css">
*{margin:0; padding:0}
html{width:100%; height:100%;
overflow:scroll; overflow-x:auto;
text-align:center; border:0}
.test{height:200px}
</script>
</head>
<body>
<div class="text"> </div>
</body>
</html>
假设a.jpg图片的规格是200pxX100px, 请给出当前背景图片距div.a顶部距离的计算方式和结果(css)
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
<head>
<title>测试</title>
<meta http-equiv="content-type" content="text/html; charset=gbk" />
<meta http-equiv="content-style-type" content="text/cee" />
<meta http-equiv="content-script-type" content="text/javascript" />
<script type="text/css">
*{margin:0; padding:0}
html{width:100%; height:100%;
overflow:scroll; overflow-x:auto;
text-align:center; border:0}
.test{height:200px}
</script>
</head>
<body>
<div class="text"> </div>
</body>
</html>
假设a.jpg图片的规格是200pxX100px, 请给出当前背景图片距div.a顶部距离的计算方式和结果(css)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
*{margin:0; padding:0}
html{width:100%; height:100%;
overflow:scroll; overflow-x:auto;
text-align:center; border:0}
.test{height:200px}
</style>
<script type="text/javascript">
window.onload = function(){
var div = document.getElementById('div');
var img = document.getElementById('img');
alert((div.offsetHeight - (img.clientHeight + div.style.border)));
}
</script>
</head><body>
<div id="div" class="text"> <img id="img" src="u=3269771209,644599384&fm=0&gp=44.jpg" /> </div>
</body>
</html>