当前位置: 首页 > news >正文

厦门建设网站公司实用网站模板

厦门建设网站公司,实用网站模板,子域名做微信开放平台网站应用,中国交通建设网站步骤#xff1a;1.实现随鼠标移动的效果#xff1b;2.初始化一个元素及其坐标#xff1b;3.拖拽对象的最后坐标#xff0c;与元素的坐标 进行计算和判断 来确定 要插入的目标元素#xff1b;4.用insertBefore 方法 插入到目标元素的前面具体代码如下#xff1a;测试的拖拽…步骤1.实现随鼠标移动的效果2.初始化一个元素及其坐标3.拖拽对象的最后坐标与元素的坐标 进行计算和判断 来确定 要插入的目标元素4.用insertBefore 方法 插入到目标元素的前面具体代码如下测试的拖拽功能body, div { margin: 0; paading: 0; font-size: 12px; }body { width: 960px; margin: 0 auto; }ul, li { margin: 0; padding: 0; list-style: none; }.clear { clear: both; width: 1px; height: 0px; line-height: 0px; font-size: 1px; }.box { width: 600px; height: auto; margin: 25px 0 0 0; padding: 5px; border: 1px solid #f00; }.main { position: static; width: 600px; height: 80px; margin-bottom: 5px; border: 1px solid blue; background: #ccc; }.maindash { position: absolute; width: 600px; height: 80px; margin-bottom: 5px; border: 1px dashed blue; background: #ececec; opacity: 0.7; }.hide { width: 600px; height: 80px; margin-bottom: 5px; }.dash { position: sta;tic; width: 600px; height: 80px; margin-bottom: 5px; border: 1px dashed #f00; };$(document).ready( function () {var range { x: 0, y: 0 };//鼠标元素偏移量var lastPos { x: 0, y: 0, x1: 0, y1: 0 }; //拖拽对象的四个坐标var tarPos { x: 0, y: 0, x1: 0, y1: 0 }; //目标元素对象的坐标初始化var theDiv null, move false;//拖拽对象 拖拽状态var theDivId 0, theDivHeight 0, theDivHalf 0; tarFirstY 0; //拖拽对象的索引、高度、的初始化。var tarDiv null, tarFirst, tempDiv; //要插入的目标元素的对象, 临时的虚线对象$(.main).each(function(){$(this).mousedown(function (event){//拖拽对象theDiv $(this);//鼠标元素相对偏移量range.x event.pageX - theDiv.offset().left;range.y event.pageY - theDiv.offset().top;theDivId theDiv.index();theDivHeight theDiv.height();theDivHalf theDivHeight/2;move true;theDiv.attr(class,maindash);// 创建新元素 插入拖拽元素之前的位置(虚线框)$(});});$(document).mousemove(function(event) {if (!move) return false;lastPos.x event.pageX - range.x;lastPos.y event.pageY - range.y;lastPos.y1 lastPos.y theDivHeight;// 拖拽元素随鼠标移动theDiv.css({left: lastPos.x px,top: lastPos.y px});// 拖拽元素随鼠标移动 查找插入目标元素var $main $(.main); // 局部变量按照重新排列过的顺序 再次获取 各个元素的坐标tempDiv $(.dash); //获得临时 虚线框的对象$main.each(function () {tarDiv $(this);tarPos.x tarDiv.offset().left;tarPos.y tarDiv.offset().top;tarPos.y1 tarPos.y tarDiv.height()/2;tarFirst $main.eq(0); // 获得第一个元素tarFirstY tarFirst.offset().top theDivHalf ; // 第一个元素对象的中心纵坐标//拖拽对象 移动到第一个位置if (lastPos.y tarFirstY) {tempDiv.insertBefore(tarFirst);}//判断要插入目标元素的 坐标后 直接插入if (lastPos.y tarPos.y - theDivHalf lastPos.y1 tarPos.y1 ) {tempDiv.insertAfter(tarDiv);}});}).mouseup(function(event) {theDiv.insertBefore(tempDiv); // 拖拽元素插入到 虚线div的位置上theDiv.attr(class, main); //恢复对象的初始样式tempDiv.remove(); // 删除新建的虚线divmovefalse;});});div1div2div3div4div5
http://www.huolong8.cn/news/109583/

相关文章:

  • 网站建设需要注意什么问题关键词自动生成器
  • 网站添加后台搜索引擎营销方法主要有三种
  • 酷炫的网站欢迎页面网站建设作业多少钱
  • 格豪网络建站深圳网站建设深圳网
  • 泊头网站建设价格wordpress+判断手机
  • 设计师网站介绍彩票网站的统计怎么做
  • 单页式网站模板asp.net 网站开发视频教程
  • 北京欢迎你网站制作公司做dj平台网站
  • 成都大型网站建设公司排名机票售票网站开发
  • 网站推广对接建设部网站注册中心
  • 六盘水遵义网站建设怎么做石家庄建站模板厂家
  • 给别人做设计的网站seo技术代理
  • 吉林哪里做网站朗域装饰口碑怎么样
  • 青岛的网站设计wp用户前端化专业版wordpress插件[中英双语]
  • 成功的门户网站网站开发需要考什么证
  • 设计网站与建设wordpress 指定阅读
  • 网站建设存在四个问题个人网站制作 教程
  • 如何建单页网站栏目公众号文章导入wordpress
  • 从化手机网站建设网站建设如何维护
  • 一个网站是如何建设外贸网站建设模式
  • seo网络贸易网站推广网站建设需要用到哪些软件有哪些
  • 怎样做淘宝联盟网站备案服务网站
  • 加盟网站制作公司怎么免费建设个人博客网站
  • 沈阳做网站的公司推荐多用户购物商城系统
  • 做餐饮公司网站设计师找灵感的网站
  • 宜兴做网站多少钱注册公司要哪些条件费用
  • 为网站网站做代理关于申请网站建设
  • 官方网站怎么找建设网站说只给前端源码是什么意思
  • 唐山公司网站建设 中企动力唐山wordpress开发
  • 深圳做网站的好公司行业网站建设多少钱