【发布时间】:2014-01-13 08:39:42
【问题描述】:
我需要一些在页面中不可见的东西、没有任何边框的东西以及根本不影响页面呈现的东西。
我需要这个来大量隐藏或显示里面的东西,比如document.getElementById("asd").innerHTML = "blah bla blah and some buttons and etc";
我希望它的标签边框不显示在页面上或根本不改变渲染。
例如,我希望渲染结果相同:
<div>
asd
<input type = "button" value = "dsa" />
<table>
<tr>
<td>zxc</td>
</tr>
</table>
qwe
</div>
和:
<div>
asd
<something id = "asd">
<input type = "button" value = "dsa" />
<table>
<tr>
<td>zxc</td>
</tr>
</table>
</something>
qwe
</div>
div 不好,因为它有边框,并且从 html 页面中的新行渲染。
<html>
<head>
<title>asd</title>
</head>
<body>
asd<div id = "test_div" style = "display: none;">dsa</div>
</body>
</html>
dsa也变得不可见
【问题讨论】:
-
<div>默认情况下,在我所知道的任何浏览器中都没有border(您是在谈论margin还是padding?)。如果你想要一个内联元素,你可以使用<span>。我还建议您使用 CSS 以您想要的方式设计样式。 -
查看
<data>标签。 -
我的意思是逻辑边界,但不是可见边界。 div 有边框,不管它是否可见。
-
他们在 CSS 上是对的。添加
display:none;和任何不可见的标签,满足您的要求。 -
display:none;确实使所有包含的东西也变得不可见,这是我不希望发生的。
标签: html containers