2012-02-09 39 views
2

我使用jQuery來隱藏DIV以下DIV點擊如何使這是一個完全可點擊DIV

.up_link { 
    position: absolute; 
    width: 830px; 
    height: 500px; 
    z-index: 8; 
    text-align: center; 
    cursor: pointer; 
    border: 3px solid #000; 
} 

這在Firefox,但不是在IE工作正常時。我可以點擊Firefox中的整個DIV,但在IE中只能看到邊框。

$(function() { 
$(".down_link").click(function() { 
    $(".gallery_block2").stop(true, true).hide().animate({ marginTop: 0 }, 400).fadeTo(500,1).show(); 
}); 

$(".up_link").click(function() { 
    $(".gallery_block2").stop(true, true).fadeTo(500,0).show().animate({ marginTop: -550 }, 400); 
}); 
}); 

HTML

<div class="gallery_block2"> 
     <div class="gallery_thumbs"> 
      <div class="gallery_close_container up_link"></div> 
      <div class="load_space"></div> 
     </div> 
    </div> 

任何幫助表示讚賞。

+1

你可以發佈你的JavaScript代碼嗎? – 2012-02-09 22:36:55

+0

我們需要看到你的JS和你的標記。通常很簡單,使用'$('。gallery_close_container')。click(...)'就足夠了。 – prodigitalson 2012-02-09 22:39:01

+0

用JQuery更新。 – Andy 2012-02-09 22:39:28

回答

4

可能的問題:沒有背景的元素(或background-color: transparent)在點擊該(非)背景時不會觸發IE中的點擊事件(至少6-8,不確定約9)。

解決方法:

1)如果您並不需要透明背景:

background-color: #000000; /* Color of whatever's behind the <div> */ 

2)如果您不需要邊框或任何文本內容:

background-color: #000000; 
filter: alpha(opacity = 0); 
opacity: 0; 
/* And vendor prefixes for older browsers, e.g. -moz-opacity */ 

...使整個元素透明,但可點擊。

3)如果你只需要IE9,火狐3和Safari 3和Opera 10的相容性(任何Chrome雲):

background-color: rgba(0, 0, 0, 0); /* Black but completely transparent */ 

...只使背景顏色透明 - 文字,邊防等遺蹟固體。整個元素將是可點擊的。

4)如果您需要透明的背景下,「全面」與舊的瀏覽器,和邊框或文本內容的兼容性:

background-image: url("1-pixel-transparent.gif"); 

...其中1個像素transparent.gif是什麼它說,這是。

就你而言,可能的選擇可能是否定的。 4.

+0

真棒幫助。爲了記錄,我使用了#2。 – Andy 2012-02-10 11:51:45

+0

好..它幫助我解決我的問題.. – 2014-11-12 15:48:04