2012-06-28 73 views
0

在IE和Firefox中呈现相同的HTML会给我一个不同的结果,因为在IE中,隐藏的复选框不会被忽略,从布局的角度来看。此图片显示,有地方隐藏复选框是在IE中的空间,但没有空间,隐藏复选框在Firefox: image shows that there is a space where the hidden checkbox is in IE, but no space where the hidden checkbox is in Firefox如何使IE和Firefox显示隐藏的元素相同(IE转换可见元素)

<html><head> 
<style type="text/css"> 
<!-- 
#checkboxhide { position: relative; visibility: hidden; font-size: 8.5pt; font-weight: font-family: verdana;} 
//--> 
</style> 
</head><body> 
<table><tr> 
<td>|</td> 
<td><span id="checkboxhide"><input type="checkbox" hidden="" name="blah"></span>|Greetings Earthings</td> 
</tr></table> 
</body></html> 

我怎样才能获得两个(或更多)的浏览器来显示一样?

+2

知名度留出空间..使用显示:无 – 2012-06-28 15:14:42

回答

4

当设置为hidden时,CSS visibility属性可以隐藏元素的内容,但不能隐藏它占据的空间。

当设置为none时,display属性隐藏了元素的内容和它占据的空间。

使用display: none而不是visibility: hidden

#checkboxhide { position: relative; display: none; font-size: 8.5pt; font-weight: font-family: verdana;} 
+0

真棒!谢谢!现在,我打算在接下来的7分钟之前做绿色复选标记? – Dale

+0

显示:内联,如果你想显示它。 – Dale