- 注册时间
- 2011-7-7
- 最后登录
- 2012-1-31
- 阅读权限
- 100
- 积分
- 337
- 精华
- 3
- 帖子
- 91
  
|
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>yj511 - - 鼠标滑过图片,图片变大</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <SCRIPT LANGUAGE="JavaScript" src='jquery-1.4.4.js'></SCRIPT>
- <script type="text/javascript">
- (function($){
- $.fn.zoomi = function() {
- $(this).filter("img").each(function(){
- if(!this.z) {
- $(this).zoom1().mouseover(function(){$(this).zoom2().show();});
- $(this.z).mouseout(function(){$(this).hide();}); }
- });
- return this;
- }
- $.fn.zoom1 = function() {
- $(this).each(function(){
- var e = this;
- $(e).css({'position':'relative','z-index':'8'}).after('<img class="'+e.className+'">');
- e.z = e.nextSibling;
- $(e.z).removeClass("zoomi").addClass("zoom2").attr("src",e.alt || e.src)
- .css({'position':'absolute','z-index':'10'});
- $(e.z).hide();
- });
- return this;
- }
- $.fn.zoom2 = function() {
- var s = [];
- this.each(function(){
- var e = this;
- if(!e.z) e = $(e).zoom1()[0]; s.push(e.z);
- if(!e.z.complete) return;
- if(!e.z.width) { $(e.z).show(); e.z.width=e.z.width; $(e.z).hide(); }
- $(e.z).css({left:$(e).offsetLeft()-(e.z.width-e.scrollWidth)/2+'px',
- top:$(e).offsetTop()-(e.z.height-e.scrollHeight)/2+'px'});
- });
- return this.pushStack(s);
- }
- $.fn.offsetLeft = function() {
- var e = this[0];
- if(!e.offsetParent) return e.offsetLeft;
- return e.offsetLeft + $(e.offsetParent).offsetLeft(); }
- $.fn.offsetTop = function() {
- var e = this[0];
- if(!e.offsetParent) return e.offsetTop;
- return e.offsetTop + $(e.offsetParent).offsetTop(); }
- $(function(){ $('img.zoomi').zoomi(); });
- })(jQuery);
- </script>
- <script type="text/javascript">
- $(function(){
- for(i=1; i<=5; ++i)
- $('#bleach img.zoomi').zoomi();
- });
- </script>
- </head>
- <body>
- <div id="bleach"><a href="#"><img height="110" src="master-css-div-shadow.jpg" class="zoomi"/></a><img class="zoom2" src="master-css-div-shadow.jpg" style="display: none;"/><a href="#"><img height="110" src="master-css-div-shadow.jpg" class="zoomi"/></a><img class="zoom2" src="master-css-div-shadow.jpg" style="display: none;"/><a href="#"><img height="110" src="master-css-div-shadow.jpg" class="zoomi"/></a><img class="zoom2" src="master-css-div-shadow.jpg" style="display: none;"/><a href="#"><img height="110" src="master-css-div-shadow.jpg" class="zoomi" /></a><img class="zoom2" src="4.jpg" style="display: none;"/><a href="#"><img height="110" src="5.jpg" class="zoomi"/></a><img class="zoom2" src="5.jpg" style="display: none;"/></div>
- </body>
- </html>
复制代码
|
|