javascript - Image Preview with jQuery, change the Hover image size -
this should simple question:
i trying use easiest tooltip , image preview using jquery trying use example
it working fine me,
my question how can change hover image size (the 1 displayed in tooltip once hovering small one) image big , want set size 200px x 200px how can that?
this current style:
<style> #preview{ position:absolute; border:1px solid #ccc; background:#333; padding:5px; display:none; color:#fff; } </style> this javascript:
this.imagepreview = function(){ /* config */ xoffset = 10; yoffset = 30; // these 2 variable determine popup's distance cursor // might want adjust right result /* end config */ $("a.preview").hover(function(e){ this.t = this.title; this.title = ""; var c = (this.t != "") ? "<br/>" + this.t : ""; $("body").append("<p id='preview'><img src='"+ this.href +"' alt='image preview' />"+ c +"</p>"); $("#preview") .css("top",(e.pagey - xoffset) + "px") .css("left",(e.pagex + yoffset) + "px") .fadein("fast"); }, function(){ this.title = this.t; $("#preview").remove(); }); $("a.preview").mousemove(function(e){ $("#preview") .css("top",(e.pagey - xoffset) + "px") .css("left",(e.pagex + yoffset) + "px"); }); }; // starting script on page load $(document).ready(function(){ imagepreview(); }); this main:
<a href="1.jpg" /*class="preview"*/><img src="1s.jpg" alt="gallery thumbnail" /></a>
add
#preview img { height:200px; } or change
$("body").append("<p id='preview'><img src='"+ this.href +"' alt='image preview' />"+ c +"</p>"); to
$("body").append('<p id="preview"><img style="height:200px" src="'+ this.href +'" alt="image preview" />'+ c +'</p>'); or
$("body").append('<p id="preview"><img style="width:200px" src="'+ this.href +'" alt="image preview" />'+ c +'</p>'); depending on how want restrict it
Comments
Post a Comment