0
我目前有一个很好的脚本,效果很好。如何使链接放大图片
当我点击图像时,缩放功能起作用。
但我需要创建一个单独的链接来缩放。
有任何建议。
jQuery.fn.center = function() {
this.css("position","absolute");
this.css("top", ($(window).height() - this.height())/2+$(window).scrollTop() + "px");
this.css("left", ($(window).width() - this.width())/2+$(window).scrollLeft() + "px");
return this;
}
$(document).ready(function() {
$("#profile_pict_lifesign img").click(function(e){
$("#background1").css({"opacity" : "0.7"})
.fadeIn("slow");
$("#large1").html("<img src='"+$(this).parent().attr("href")+"' alt='"+$(this).attr("alt")+"' /><br/>"+$(this).attr("rel")+"")
.center()
.fadeIn("slow");
return false;
});
$(document).keypress(function(e){
if(e.keyCode==27){
$("#background1").fadeOut("slow");
$("#large1").fadeOut("slow");
}
});
$("#background1").click(function(){
$("#background1").fadeOut("slow");
$("#large1").fadeOut("slow");
});
$("#large1").click(function(){
$("#background1").fadeOut("slow");
$("#large1").fadeOut("slow");
});
});
<div id="profile_pict_lifesign"><img src="pic_memory.jpg" alt="" rel=""><a href="pic_memory.jpg">zoom</a>
<div id="profile_specs_wrap">
<div id="profile_specs_1">LIFESIGN #203</div>
<div id="profile_specs_2">Louis Tharp</div>
<div id="profile_specs_3">Born: September 20, 1964</div>
<div id="profile_specs_4">Home City & State: Indianapolis, Indiana</div>
<div id="profile_specs_5">Homeless Status: "Still Homeless"</div>
<div id="profile_specs_6">Homeless Timer: 4 Years, 3 Months, & 4 Days</div>
</div>
<div id="profile_specs_wrap2">
<div id="profile_specs_7">This is a photograph of Louis with his two loving sisters in 1969.</div>
</div>
</div>
<div id="large1"></div>
<div id="background1"></div>
尝试创建新的HTML文档,克隆的jQuery,fn.center,图像,从打开的文档到新的HTML文档,打开新的HTML在单击事件时在新窗口中文档,在窗口加载事件回调中调用fn.center。 – guest271314