日期:2014-05-16  浏览次数:20265 次

菜鸟的一个简单的问题,。。。
网页中有几个DIV,是竖着排下来的,id 分别为 div1,div2,div3, 我想在生成页面后,只显示最上边的div1,下面的div2,div3
display:"none",不让其显示,可是问题来了,虽然没显示,可是隐藏的div2,div3照样还是占着原本的那个位置,恨不美观,
要怎么设置才能既能隐藏又能把它本来占有的位置去掉呢?ps:后来我设置visibility:"hidden",还是不行,请帮忙

------解决方案--------------------
那就奇怪了,display:none是完全不占位置的,只有visibility:hidden才是隐藏而占位置的,建议把代码帖出来测试。
------解决方案--------------------
L@_@K
HTML code
<!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>
    <title> new document </title>
    <meta name="generator" content="editplus" />
    <meta name="author" content="Gao YiXiang" />
    <meta name="email" content="yixianggao@126.com" />
    <meta name="keywords" content="javascript dhtml dom" />
    <meta name="description" content="I love web development." />
</head>
<body>
    <div id="div1" style="background-color: red; width: 100px; height: 300px;"></div>
    <div id="div2" style="display: none; background-color: green; width: 100px; height: 300px;"></div>
    <div id="div3" style="display: none; background-color: blue; width: 100px; height: 300px;"></div>
</body>
</html>