在实际应用中为了特殊的需要而用到一个空的DIV,并定义一个较小的高度值.通常的想法见下面代码:
HTML
<div></div>
CSS
div{
height:5px;
}
以上代码在多数浏览器中都可正确显示,但我们在实际运用中,确不象理论上这么简单,特别的IE6中并非如你所想,好象有时可以定义高度,有时它就不知何原因失效了!
先给出我的测试代码,然后在详细说明:
<!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=utf-8″ />
<title>无标题文档</title>
<style type=”text/css”>
h3{margin:10px 0;padding:0;}
body{background:white; color:black; font-size:12px;}
.content{width:400px;border:solid 1px red;}
p{color:black;background:green;margin:0;padding:0;}
.t{height:6px;width:600px;background:red;}
.b{width:200px; background:#000;height:5px;}
.b0{background:#000; font-size:0px;}
.b1{width:200px; background:#000; font-size:1px;}
.b2{width:200px; background:#000; font-size:2px;}
.b3{width:200px; background:#000; font-size:3px;}
.b4{width:200px; background:#000; font-size:4px;}
.b5{width:200px; background:#000; font-size:5px;}
.b6{width:200px; background:#000; font-size:6px;}
.b7{width:200px; background:#000; font-size:7px;}
.b8{width:200px; background:#000; font-size:8px;}
.b9{width:200px; background:#000; font-size:9px;}
.b10{width:200px; background:#000; font-size:10px;}
.b11{width:200px; background:#000; font-size:11px;}
.b12{width:200px; background:#000; font-size:12px;}
</style>
</head>
<body>
<h2>空DIV在IE6浏览器中的不同表现形式</h2>
<h3>一.空DIV无样式时的表现</h3>
<div class=”content”>
<p>something</p>
<div></div>
第 1 2 3 4 页