簡體   English   中英

如何使其成為完全可點擊的DIV

[英]How to make this an entirely clickable DIV

單擊以下DIV時,我正在使用JQuery隱藏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>

任何幫助表示贊賞。

可能的問題:沒有背景(或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,Firefox 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-pixel-transparent.gif是它所說的。

在您的情況下,可能的選擇可能是“否”。 4。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM