javascript - jquery: display one element on top of another and disable mouse hover event on it -
here fiddle: http://jsfiddle.net/5lfqr/
the fiddle contains html pair of images (thumb , big):
<div class="wrapper"> <a href="http://cssglobe.com/lab/tooltip/02/1.jpg" class="preview" title=""> <img src="http://cssglobe.com/lab/tooltip/02/1s.jpg" alt="gallery thumbnail"> </a> </div>
the idea display big image when user hovers mouse on thumbnail.
this solution simple , works except 1 thing: originally, offset of big image right , down of mouse position. big image over thumb, should cover it. when implement it, changing offset this:
xoffset = -100; yoffset = -100;
the big image flickers. it's because mouse cursor on thumb , @ same time on big, can't decide do. big image should become transparent hover.
is there solution it?
you way:
place preview behind thumbnail , turn thumbnail transparent on mouse-enter:
$(this).css("opacity", "0");
you need turn make opaque when mouse leaves:
$("a.preview").mouseleave(function(e){ $(this).css("opacity", "1") });
however, feels little awkward me... , not best way accomplish doing. think can of (if not all) css using pseduo elements. mess around fiddle bit , see.
edit
with css (at it's basic). wanted use pseudo elements.. couldn't work images (you using background images, not sure if better):
the html
<div class="wrapper"> <img src="http://cssglobe.com/lab/tooltip/02/1s.jpg" class="thumb"> <img src="http://cssglobe.com/lab/tooltip/02/1.jpg" class="full"> </div>
the css:
.wrapper { position: relative; width: 100px; top: 150px; height:75px; margin: auto; } .thumb { position:relative; z-index:2; } .full { position:absolute; left:50%; margin-left:-200px; top:50%; margin-top:-150px; z-index:1; display:none; } .wrapper:hover .full { display:block; } .wrapper:hover .thumb { display:none; }
you trigger way, if want preview close when outside of thumb area (not sure why would):
.thumb:hover ~ .full { display:block; } .thumb:hover { opacity:0; }
Comments
Post a Comment