js实现图层随意拖动特效实例

2周前 (04-27 13:32)阅读10回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值4289
  • 级别管理员
  • 主题857
  • 回复2
楼主

通过js实现图层随意拖动效果,用鼠标压住鼠标左键拖动图层即可,根据自己的需求来修改样式即可使用。

<!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=gb2312" />
<meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren">
<meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。">
<title>js实现图层随意拖动特效实例_武鸣人</title>
<style type="text/css">
#wwwwumingren div{position:absolute;width:220px;height:150px;border:1px solid #999;}
</style>
<script type="text/javascript">
var a;
document.onmouseup=function(){if(!a)return;document.all?a.releaseCapture():window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);a="";};
document.onmousemove=function (d){if(!a)return;if(!d)d=event;a.style.left=(d.clientX-b)+"px";a.style.top=(d.clientY-c)+"px";};
function $(o,e){a=o;document.all?a.setCapture():window.captureEvents(Event.MOUSEMOVE);b=e.clientX-parseInt(a.style.left);c=e.clientY-parseInt(a.style.top);}
</script>
</head>
<body>
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr>
<!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。-->
<script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script>
<script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script>
  <div id="wwwwumingren">
    <div style="left:100px;top:100px;background:#fc9;" onmousedown="$(this,event)">武鸣人一号图层</div>
    <div style="left:400px;top:100px;background:#9cf;" onmousedown="$(this,event)">武鸣人二号图层</div>
    <div style="left:700px;top:100px;background:#f9c;" onmousedown="$(this,event)">武鸣人三号图层</div>
    <div style="left:100px;top:300px;background:#9fc;" onmousedown="$(this,event)">武鸣人四号图层</div>
    <div style="left:400px;top:300px;background:#c9f;" onmousedown="$(this,event)">武鸣人五号图层</div>
    <div style="left:700px;top:300px;background:#cf9;" onmousedown="$(this,event)">武鸣人六号图层</div>
  </div>
</body>
</html>


0
0
收藏0
回帖

js实现图层随意拖动特效实例 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息