2012-06-28 72 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