div自由拖拽
2015-11-05 18:11
316 查看
div自由拖拽
<!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" /> <title>无标题文档</title> <script src="jquery-1.11.1.min.js"></script> <script src="base64.js"></script> <style> .s1{ position:fixed; top:100px; left:200px; background:#00F; width:200px; height:50px; border-radius:70%; } .s0{ width:1000px; height:1000px; } .s2{ position:fixed; top:100px; left:300px; background:#F00; width:400px; height:50px; border-radius:70%; } .s3{ position:fixed; top:100px; left:400px; background:#CF6; width:100px; height:200px; border-radius:70%; } .s4{ position:fixed; top:100px; left:500px; background:#F06; width:200px; height:150px; border-radius:70%; } .s5{ position:fixed; top:100px; left:500px; background:#000; width:20px; height:20px; border-radius:70%; } .s6{ position:fixed; top:100px; left:500px; background:#000; width:20px; height:20px; border-radius:70%; } .s7{ position:fixed; top:100px; left:500px; background:#C30; width:20px; height:150px; border-radius:70%; } .s8{ position:fixed; top:100px; left:500px; background:#C30; width:20px; height:150px; border-radius:70%; } *,.body{ height:2000px;; } </style> <script> $(document).ready(function(){ var sslist=$("#s0 #ss"); alert(sslist.length); sslist.mousedown(function(event) { var isMove = true; var abs_x = event.pageX - $(this).offset().left; var abs_y = event.pageY - $(this).offset().top; var index=sslist.index($(this)); $(document).mousemove(function(event) { if (isMove) { var obj = $("#s0 #ss").eq(index); obj.css({'left':event.pageX - abs_x, 'top':event.pageY - abs_y}); } }); $(document).mouseup(function(event) { isMove = false; }); }); }); var xx="aHR0cA=="; alert(Base64.decode(xx)); </script> </head> <body> fasfdsafdsafdasfdsaf <div id="s0"> <div id="ss" class="s1"></div> <div id="ss" class="s2"></div> <div id="ss" class="s3"></div> <div id="ss" class="s4"></div> <div id="ss" class="s5"></div> <div id="ss" class="s6"></div> <div id="ss" class="s7"></div> <div id="ss" class="s8"></div> <div> </body> </html>
相关文章推荐
- [div+css]晒晒最新制作专题推广页模板
- html小技巧之td,div标签里内容不换行
- div flash firefox div层总是被flash层遮盖
- 小技巧处理div内容溢出
- 让超出DIV宽度范围的文字自动显示省略号...
- 解决div被flash挡住的设置方法
- 网页中Span和Div的区别
- DIV+CSS经常用到的属性、参数及说明
- CSS Div 最小高度在IE 6 和IE 7中的兼容性问题
- DIV CSS网页布局 最小高度(min-height)的妙用
- DIV border边框显示不完全问题的解决方法
- Div CSS absolute与relative的区别小结
- 图片垂直居中之姊妹 DIV垂直居中
- 基于Jquery+div+css实现弹出登录窗口(代码超简单)
- WinForm拖拽控件生成副本的解决方法
- 支持IE,firefxo,chrome浏览器下鼠标拖动和拖拽的鼠标指针特效
- div scroll始终在最底部的实现代码
- div层跨越iframe帧显示在上面的解决方法附代码
- js实现完美拖拽效果可拖动层与回放拖动规迹并显示拖动距离参数
- JS实现点击按钮控制Div变宽、增高及调整背景色的方法