6

我有四个 div 元素,在鼠标悬停时,选定的 div 将被放大。但是我需要获取其余三个底层 div 的 mouseover 事件,即使另一个被覆盖,这样我就可以使较早的一个不缩放并且当前悬停的一个缩放。

请考虑我的小提琴:http: //jsfiddle.net/aniprasanth/7jFGH/1/

HTML代码是这样的

<div id="main_window">
                <div class="multi-window">
                    <div class="zoomer tile">
                        <img src="images/img1.jpg" width="207" height="138" />
                    </div>
                 </div>
              <div class="multi-window">
                    <div class="zoomer tile">
                        <img src="images/img2.jpg" width="207" height="138" />
                    </div>
                 </div>
             <div class="multi-window">
                    <div class="zoomer tile">
                        <img src="images/img3.jpg" width="207" height="138" />
                    </div>
                 </div>
              <div class="multi-window">
                    <div class="zoomer tile">
                        <img src="images/img4.jpg" width="207" height="138" />
                    </div>
                 </div>
            </div>

CSS 是这样的:

#main_right #main_window {
height: 320px;
width: 460px;
margin-right: auto;
margin-left: auto;
margin-top: 20px;
position: relative;

}
.multi-window {
height: 150px;
width: 218px;
float: left;
margin-right: 11px;
margin-bottom: 10px;
cursor: pointer;
}
.zoomer {
height: 140px;
width: 208px;
cursor:pointer;
}
.zoom {
height: 301px;
width: 450px;
float:none;
margin:0px;
cursor:pointer;
position:absolute;
left:0;
top:0;
background-color:#FFF;
}
.multi-window img {
width:100% !important;
height:100% !important;
}

最后是脚本:

$('.zoomer').on('mouseenter',function(e){
        $(this).addClass('zoom').removeClass('zoomer');
        $('.zoom img').css({
            'width':'100%',
            'height':'100%'
            });

            $(this).bind('mouseleave click', function(){

                $(this).removeClass('zoom').addClass('zoomer');
                $('.zoomer').removeClass('zoomer'); 


                });
        });
4

1 回答 1

13

将此 CSS 属性用于覆盖 Div。

pointer-events: none

这将禁用该 div 上的所有点击事件,并将所有点击事件传递到其下方的图层。

于 2013-08-13T07:46:05.807 回答