javascript - Script isn't creating span -
javascript - Script isn't creating span -
this script utilize create span under image show background image on hover
$(".gallery li a.image, .portfolio li a.image").append('<span class="image_hover"></span>'); //add span images $(".gallery li a.video, .portfolio li a.video").append('<span class="video_hover"></span>'); //add span videos $('.gallery li span').css('opacity', '0').css('display', 'block') //span opacity = 0 // show / hide span on hover $(".gallery li a, .portfolio li a").hover( function () { $(this).find('.image_hover, .video_hover').stop().fadeto('slow', .7); }, function () { $('.image_hover, .video_hover').stop().fadeout('slow', 0); });
this css code:
#gallery_prettyphoto.portfolio {padding: 0 0 20px 0; overflow: hidden; } #gallery_prettyphoto.portfolio ul li { display: inline-block; height: 400px; margin-bottom:35px; } #gallery_prettyphoto.portfolio ul li img {border: none; margin-top: 30px;} /*#gallery_prettyphoto.portfolio:hover ul li img {width: 120%;}*/ #gallery_prettyphoto.portfolio ul li h3 {text-decoration: none; text-align: center;} #gallery_prettyphoto.portfolio ul li p {margin: 10px 0 15px 0;} #gallery_prettyphoto.portfolio ul li a.more-link {-moz-border-radius: 3px; /* ff1-3.6 */ -webkit-border-radius: 3px; /* saf3-4, ios 1-3.2, android <1.6 */ border-radius: 3px; /* opera 10.5, ie9, saf5, chrome, ff4, ios 4, android 2.1+ */ border: 1px solid #2c2c2c; background: #111111; text-align: center; padding: 3px 10px; width: 80px; display: block; color: white; text-decoration: none;} #gallery_prettyphoto.portfolio ul li a.more-link:hover {background: #222222;} #gallery_prettyphoto.portfolio span { z-index: 2000; position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; cursor: pointer; } .portfolio .gallery_2columns {position: relative; display: block;} .portfolio .gallery_3columns {position: relative; display: block;} .portfolio .gallery_2columns span.image_hover {background: black url(images/gallery_hover/hover_image_big.png) no-repeat center center; } .portfolio .gallery_2columns span.video_hover {background: black url(images/gallery_hover/hover_video_big.png) no-repeat center center; } .portfolio .gallery_3columns span.image_hover {background: black url(images/gallery_hover/hover_image_medium.png) no-repeat center center; } .portfolio .gallery_3columns span.video_hover {background: black url(images/gallery_hover/hover_video_medium.png) no-repeat center center; }
if there no solution, can guide me creating similar effect on hover, zoom image, or opacity change.
try this
change this: $(".gallery li a.image, .portfolio li a.image").append('<span class="image_hover"></span>');
to this: $(".gallery li a.image, .portfolio li a.image").append("<span class='image_hover'></span>");
javascript jquery css hover html
Comments
Post a Comment