IE6/7 and IE8/9/10(IE7模式)依次隱藏具有absolute或relative的父元素和子項目後再顯示

來源:互聯網
上載者:User

如下
1,兩個div,d1中包含d2
2,d1,d2都設定了absolute或relative
3,隱藏d1
4,隱藏子項目d2
5,顯示d1
這時IE6/7 and IE8/9/10(IE7模式)中會發現,子項目d2也能顯示出了(別忘了,d2被display:none 了哦)。但IE8/9/10/Firefox5/Safari4/Chrome12中子項目d2仍然是被隱藏的。
重現代碼
複製代碼 代碼如下:
<!DOCTYPE HTML>
<HTML>
<HEAD>
<meta charset="utf-8" />
<title>IE6/7 and IE8/9/10(IE7模式)依次隱藏具有absolute或relative的父元素和子項目後再顯示父元素,子項目依然能顯示bug</title>
</HEAD>
<BODY>
<p>
<button onclick="hidden_d1()">1) 隱藏div[id=d1]</button>
<button onclick="hidden_d2()">2) 隱藏div[id=d2]</button>
<button onclick="display_d1()">3) 顯示div[id=d1]</button>
</p>
<div id="d1" style="position:absolute;width:200px;height:200px;border:1px solid gray;">
<div id="d2" style="position:absolute;width:100px;height:100px;background:gold;"></div>
</div>
<script>
var d1 = document.getElementById('d1');
var d2 = document.getElementById('d2');
function hidden_d1() {
d1.style.display = "none";
}
function hidden_d2() {
d2.style.display = "none";
}
function display_d1() {
d1.style.display = "block";
}
</script>
</BODY>
</HTML>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.