div选中效果及鼠标指针变形
来源:互联网 发布:java b2b开源电商平台 编辑:程序博客网 时间:2024/06/05 23:58
这个功能,很多框架,如mxGraph都有,但是他们的集成太复杂,我自己做了一个效果。
先上效果图
第一个的效果。
我看到mxGraph是用的svg实现的,我现在需要用div实现。但是参考了一点mxGraph的思路。
1、选中目标时,添加几个小的div,我分别加的是四个边,四个角,四个中点,一共是12个div
//四条边active.append(createMyElement(width + borderWidth,borderWidth,- borderWidth/2,- borderWidth/2,"activeBorder"));active.append(createMyElement(width + borderWidth,borderWidth,- borderWidth/2,height- borderWidth/2,"activeBorder"));active.append(createMyElement(borderWidth,height + borderWidth,- borderWidth/2,- borderWidth/2,"activeBorder"));active.append(createMyElement(borderWidth,height + borderWidth,width - borderWidth/2,-borderWidth/2,"activeBorder"));//四个顶点active.append(createMyElement(pointWidth,pointWidth,- pointWidth/2,- pointWidth/2,"activeBorder"));active.append(createMyElement(pointWidth,pointWidth,- pointWidth/2,height- pointWidth/2,"activeBorder"));active.append(createMyElement(pointWidth,pointWidth,width - pointWidth/2,- pointWidth/2,"activeBorder"));active.append(createMyElement(pointWidth,pointWidth,width - pointWidth/2,height - pointWidth/2,"activeBorder"));//四个中点active.append(createMyElement(pointWidth,pointWidth,width/2 - pointWidth/2,- pointWidth/2,"activeBorder"));active.append(createMyElement(pointWidth,pointWidth,width/2 - pointWidth/2, height - pointWidth/2,"activeBorder"));active.append(createMyElement(pointWidth,pointWidth,- pointWidth/2,height/2 - pointWidth/2,"activeBorder"));active.append(createMyElement(pointWidth,pointWidth,width - pointWidth/2, height/2 - pointWidth/2,"activeBorder"));其中,createMyElement()方法:
function createMyElement(width,height,left,top ,className){var element = document.createElement("div");element.style.width = width + "px";element.style.height= height+"px";element.style.top = top + "px";element.style.left = left + "px";if(className){element.className = className;}return element;}
2、鼠标移到对应的点上,鼠标的指针会进行变化
.active .activeBorder:nth-child(5){cursor:nw-resize;}.active .activeBorder:nth-child(6){cursor:sw-resize;}.active .activeBorder:nth-child(7){cursor:sw-resize;}.active .activeBorder:nth-child(8){cursor:nw-resize;}.active .activeBorder:nth-child(9){cursor:n-resize;}.active .activeBorder:nth-child(10){cursor:n-resize;}.active .activeBorder:nth-child(11){cursor:w-resize;}.active .activeBorder:nth-child(12){cursor:w-resize;}
核心就是这样。
源代码下载
0 0
- div选中效果及鼠标指针变形
- Div鼠标移动效果
- 鼠标移动div效果:鼠标拖曳效果
- DIV滚动 鼠标悬停效果
- jquery table 鼠标选中单元格效果
- 纯css好看的div选中效果
- 鼠标悬停div翻转效果,记录自己制作时踩得一些坑及解决方案
- js 实现 鼠标拖动DIV 效果
- CSS鼠标悬停div加边框效果
- jQuery实现鼠标拖拽div效果
- textarea不能选中及定位 鼠标问题
- 如何让鼠标移入div不选中div中的文字,鼠标也改变样式
- 禁止鼠标多次点击选中div中的文字
- 禁止鼠标多次点击选中div中的文字
- 取消页面鼠标左键选中高亮显示效果
- 变形效果
- Unity考虑做个zbrush效果 mesh 鼠标挤压变形效果,compute shader
- winform 鼠标指针移过组件选中行勾选移开未选中去除勾选
- Python的图片处理-待续
- php实现时间戳转换在32位系统下超过2038年的自定义处理函
- Spring实现AOP的4种方式
- [iOS] gitHUB 冲突方法 Line XX: StartTag: invalid element name
- 佛祖保佑,永无bug
- div选中效果及鼠标指针变形
- Spring环境中支持多数据库源连接的配置及使用方法
- ReactJS学习系列课程2(React环境搭建)
- 时间与日期的转换
- 2016.06.24回顾
- 在ListView的item项里使用CheckBox或者Button时,OnItemClickListener无响应的问题
- Android5.0中Cardview的简单使用
- sockfd连接后如何获得对方和本机的ip地址和端口
- 第16周小玩文件