需求:
原理:
拖动效果的实现基本都是dom操作来实现的,通过拖动分隔线,计算分隔线与浏览器边框的距离(left),来实现拖动之后的不同宽度的计算;当拖动分隔线1时,计算元素框left和mid;当拖动分隔线2时,计算元素框mid和right;同时设置元素框最小值以防止元素框拖没了(其实是被遮住了)。使用SetCapture() 和 ReleaseCapture()的函数功能指定窗口里设置鼠标捕获。
html部分代码:
- 西瓜
- 备注2
- test
- 芒果
- 备注
- test
js部分代码:
style部分:
ul,li{ list-style: none; display: block; margin:0; padding:0; } .box{ width:800px; height:32px; overflow:hidden; } .left{ width:calc(30% - 10px); height:100%; background:skyblue; float:left; } .resize{ width:5px; height:100%; cursor: w-resize; float:left; } .resize2{ width:5px; height:100%; cursor: w-resize; float:left; } .right{ float:left; width:35%; height:100%; background:tomato; } .mid{ float:left; width:35%; height:100%; background:#f00; }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



