恒美微站 Logo 恒美微站
  • 首页
  • 关于我们
  • 建站服务
  • 主题模板
  • 案例展示
  • 资讯中心
  • 联系我们

实现移动端(PC端)div拖拽自动排列功能

  • 首页
  • 资讯中心
  • /
  • 实现移动端(PC端)div拖拽自动排列功能

相关资讯

【Stable Diffusion】微调LoRA基础使用 2026/9/18 14:31:52
国企内审大数据应用:从合规取数到审计模型工程化落地 2026/9/18 14:31:52
OCI 镜像进 Daytona 沙箱,Agent 靠 TaoToken 填 Key 2026/9/18 14:31:52

最新资讯

Keil MDK优化等级详解:从-O0到-O3的陷阱与调试技巧
DeepSeek本地部署实战:Ollama+Docker接入工作流与知识库
把 Rene 的模型入口指向 TaoToken,观察 newsletter 筛选的 Token 账
实验报告格式PDF化:LaTeX与Markdown双流水线实践指南
Trae 跑 Builder/Chat 智能体:Key 用 TaoToken
数据驱动落地:Event模型与埋点体系工程实践

今日推荐

2026年AI设计工具在PPT制作中的核心应用与评测
Matlab手写逻辑回归:从数学原理到多变量概率预测模型实现
高值医用耗材研报PDF:用Python完成字段抽取、清洗与趋势预测

本周热门

AI SDK Harness 依赖更新指南:掌握 harness 包 SDK 依赖的升级、桥接同步与一致性校验
Refine v5 Ant Design NumberField 组件实战:基于 Intl 的本地化数字格式化
Flutter应用改名全指南:从Android到iOS的配置与工具实践

本月精选

自研推理加速器Redwood:两周内实现PyTorch模型高效部署的实战教程
V4L2摄像头采集实战:从camera_client.rar到出图全流程解析
从“谁发明了钢琴键”到知识问答智能体:RAG与记忆工程实践

实现移动端(PC端)div拖拽自动排列功能

发布时间:2026/9/18 14:36:52
实现移动端(PC端)div拖拽自动排列功能 1、进入画面后按下F12手机或iPad都可以拖拽拖拽完成后会自动排列。!DOCTYPEhtmlhtmllangenheadmetacharsetutf-8metahttp-equivX-UA-CompatiblecontentIEedgemetanameviewportcontentwidthdevice-width, initial-scale1, shrink-to-fitnotitle123/titlestyle*{padding:0;margin:0;}html,body{width:100%;height:100%;}.wrap{position:relative;width:600px;height:350px;margin:100pxauto;border:solid1pxwhite;}.wrapdiv{position:absolute;z-index:1;width:100px;height:100px;text-align:center;align-items:center;transition:all.5s;}.red{background-color:tomato;color:white;border-radius:15px;}.red-child{border:solid1pxtomato;}.children{color:grey;}.green{background-color:yellowgreen;color:white;border-radius:15px;}.green-child{border:solid1pxyellowgreen;background-origin:padding-box;}.blue{background-color:rgb(29,167,231);color:white;border-radius:15px;}.blue-child{border:solid1pxrgb(29,167,231);}/style/headbodyclassapp header-fixed sidebar-fixed sidebar-hidden aside-menu-fixed aside-menu-hiddenstyletext-align:centerdivclasswrapidelWrapdivclassred保安月次/divdivclasschildren red-child自分/divdivclasschildren red-child月次/divdivclasschildren red-child自分/divdivclasschildren red-child月次/divdivclassgreen保安年次/divdivclasschildren green-child年次/divdivclasschildren green-child年次入力/divdivclassblue他/divdivclasschildren blue-child工程/divdivclasschildren blue-child保安台客/div/div/body/htmlscriptletindex0;letelArrdocument.getElementById(elWrap).children;letelList[];//构造一个数组for(leti0;ielArr.length;i){elList.push({el:elArr[i],sort:i,index:i});elList[i].onclickaddEvent(elList[i]);}moveItem(elList);functionaddEvent(item){item.el.addEventListener(touchstart,(e){item.el.style.zIndex2;item.el.style.transitionall 0s;vartouch;if(event.touches){touche.touches[0];}else{touche;}letstartXtouch.pageX,startYtouch.pageY,leftitem.el.offsetLeft,topitem.el.offsetTop;letmoveFun(e){vartouch;if(event.touches){touche.touches[0];}else{touche;}letXtouch.pageX-startXleft;letYtouch.pageY-startYtop;item.el.style.left${X}px;item.el.style.top${Y}px;reRange(item,X,Y);};document.addEventListener(touchmove,moveFun);item.el.addEventListener(touchend,(){document.removeEventListener(touchmove,moveFun);item.el.style.zIndex1;item.el.style.transitionall .5s;moveItem(elList);});});}functionreRange(item,x,y){letmoveIndexMath.round(x/125)Math.round(y/125)*5;moveIndexmoveIndex0?0:moveIndex;moveIndexmoveIndexelList.length-1?elList.length-1:moveIndex;if(moveIndex!index){indexmoveIndex;letcurrentSortitem.sort;for(leti0;ielList.length;i){if(currentSortmoveIndex){if(elList[i].sortcurrentSortelList[i].sortmoveIndex){elList[i].sort-1;};}elseif(currentSortmoveIndex){if(elList[i].sortcurrentSortelList[i].sortmoveIndex){elList[i].sort1;};}};elList[item.index].sortmoveIndex;moveItem(elList);}}//排列functionmoveItem(elList){for(leti0;ielList.length;i){elList[i].el.style.leftelList[i].sort%5*125px;elList[i].el.style.topparseInt(elList[i].sort/5)*125px;}}/script2、PC端的话把js代码中的touchstart、touchmove、touchend分别替换成mousedown、mousemove、mouseup即可。

关于恒美微站

恒美微站专注于为个体商户、工作室提供极简自助建站服务,让每个人都能轻松拥有专业网站。

快速链接

  • 关于我们
  • 建站服务
  • 主题模板
  • 案例展示
  • 资讯中心

服务项目

  • 可视化建站
  • 拖拽编辑
  • 主题定制
  • SEO 优化
  • 网站托管

联系方式

  • 📍 地址:北京市朝阳区建国路 88 号
  • 📞 电话:400-888-8888
  • ✉️ 邮箱:info@hmyw.cn
  • 🕐 时间:周一至周日 9:00-18:00

© 2024 恒美微站 hmyw.cn 版权所有 | 京 ICP 备 12345678 号