AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > JavaScript

jquery实现仿新浪微博带动画效果弹出层代码(可关闭、可拖动)

51自学网 http://www.wanshiok.com
jquery,仿新浪微博,动画效果,弹出层,jquery弹出层

本文实例讲述了jquery实现仿新浪微博带动画效果弹出层代码。分享给大家供大家参考。具体如下:

这是一款jquery实现带动画的弹出层,最开始是模拟新浪微博中的弹出层,后来引入了jQuery,又想了想,加入点动画效果不知怎么样,后来就写出了这么一个弹出的网页层效果,你点击按钮后就可以看到一个渐出的可关闭的弹出层,点击关闭后,当然也是渐渐的消失的,移动时根据鼠标位置计算控件左上角的绝对位置,松开鼠标后停止移动并恢复成不透明。

运行效果截图如下:

在线演示地址如下:

http://demo.wanshiok.com/js/2015/jquery-f-sina-flash-style-close-able-dlg-demo/

具体代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script src="jquery-1.6.2.min.js" type="text/javascript"></script><style type="text/css">#t{ margin:30px 0 0 100px;}.cc {  border:1px solid #000;  position:absolute;  top:60px;  left:180px;  height: 150px;  width: 300px;  display:none;}.cc h2{ display:block; width:270px; font-size:12px; float:left; text-align:center;}.cc span{ display:block; width:20px; height:20px; font-size:18px; float:right; border:1px solid #F00; background:#999; text-align:center;}</style><script language="javascript">$(function(){  var _move=false;//移动标记  var _x,_y;//鼠标离控件左上角的相对位置  $('#t').click(    function(){    $('.cc').fadeIn('slow');      });  $('.cc span').click(function(){      $('.cc').hide('fast');      })  $('.cc').mousedown(function(e){    _move=true;  _x=e.pageX-parseInt($(".cc").css("left"));  _y=e.pageY-parseInt($(".cc").css("top"));  $(".cc").fadeTo(20, 0.5).css('cursor','move');//点击后开始拖动并透明显示    });   $('.cc').mousemove(function(e){  if(_move){   var x=e.pageX-_x;//移动时根据鼠标位置计算控件左上角的绝对位置   var y=e.pageY-_y;   $(".cc").css({top:y,left:x});//控件新位置  } }).mouseup(function(){ _move=false; $(".cc").fadeTo("fast", 1).css('cursor','auto');//松开鼠标后停止移动并恢复成不透明 });});</script><title>新浪微博的弹出层效果</title></head><body><input id="t" name="1" type="button" value="弹出层" /><div class="cc"><h2>点击可以拖拽哦</h2><span>X</span></div></body></html>

希望本文所述对大家的jQuery程序设计有所帮助。


jquery,仿新浪微博,动画效果,弹出层,jquery弹出层  
上一篇:JS实现新浪微博效果带遮罩层的弹出框代码  下一篇:关于事件mouseover ,mouseout ,mouseenter,mouseleave的区别