IE6下png背景不透明問題的綜合拓展

轉載自:http://www.zhangxinxu.com/wordpress/?p=14


注意事例中:

background-image背景透明內部標籤單擊事件不響應

<div style="width:128px; height:128px; padding-bottom:10px; text-align:center; background:url(../image/png_test.png) no-repeat; float:left;">

    <a href="#nogo" style="display:inline-block; padding:2px 6px; margin-top:30px; background:white; border:1px solid #333333;" οnclick="alert('點得我好癢啊!');">單擊我</a>

</div>

div標籤包含住a標籤;

解決方法——覆蓋

所謂覆蓋是指用一個外部的標籤定位到此內部點擊失效的div層上。例如這裏,可以將"單擊我"這個a標籤卸載覆蓋在含透明png背景圖片的DIV之外,用絕對定位或margin複製法定位到想要的區域或是用一個外部透明層覆蓋在“單擊我”這個區域上。

由於IE6下有時會出現絕對定位裏面元素不可見的奇怪bug,所以我建議用margin負值實現定位效果。本例子中我就是將點擊的a標籤提到div之外,margin負值(margin-left:-100;)定位到此div之上的,如下面示例代碼。

<div style="width:128px; height:128px; padding-bottom:10px; background:url(../image/png_test.png) no-repeat; float:left;"></div>

<a href="#nogo" style="display:inline-block; float:left; padding:2px 6px; margin-top:30px; margin-left:-100px; background:white; border:1px solid #333333;" οnclick="alert('點得我好癢啊!');">單擊我</a>




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章