博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
html 可拖动宽度的div方法
阅读量:6968 次
发布时间:2019-06-27

本文共 1312 字,大约阅读时间需要 4 分钟。

hot3.png

效果演示:

HTML:

鼠标移动到矩形分割线

JS:

$(function () {    $(".resizable1").resizable(    {        autoHide: true,        handles: 'e',        resize: function(e, ui)         {            var parent = ui.element.parent();            var remainingSpace = parent.width() - ui.element.outerWidth(),                divTwo = ui.element.next(),                divTwoWidth = (remainingSpace - (divTwo.outerWidth() - divTwo.width()))/parent.width()*100+"%";                divTwo.width(divTwoWidth);        },        stop: function(e, ui)         {            var parent = ui.element.parent();            ui.element.css(            {                width: ui.element.width()/parent.width()*100+"%",            });        }    });});

CSS:

@import url('http://cdn.gbtags.com/jqueryui/1.10.4/css/jquery-ui.min.css');*{  font-family: 'microsoft yahei',Arial,sans-serif;}.wrap {    width: 100%;    border: 1px solid #999;    font-size: 0;}h4{  font-weight: normal;}.resizable {    width: 50%;    height: 120px;    padding: 0.5em;    background-color: orange;    display: inline-block;}.resizable2 {    background-color: #08a3ca;}.ui-resizable-e {     cursor: e-resize;     width: 16px;     right: -5px;     top: 0;     bottom: 0;     background-color: #666;}

 

转载于:https://my.oschina.net/u/2391658/blog/1535792

你可能感兴趣的文章
go语言中的数组
查看>>
对做技术的反思
查看>>
TP框架中模糊查询实现
查看>>
分布式事物的原理图
查看>>
cocos2dx编译安卓版本号查看C++错误
查看>>
Spark学习笔记——房屋价格预测
查看>>
Tutorial: Generate BBox or Rectangle to locate the target obejct
查看>>
Anton and Letters
查看>>
阿里云服务器带宽跑满怎么办
查看>>
java maven通过SMTP发送QQ邮件的完全步骤
查看>>
结构型模式—适配器模式
查看>>
(转)淘淘商城系列——在业务逻辑中添加缓存
查看>>
JS在在线人数和访问人数
查看>>
Maven 拾遗
查看>>
CentOS Boost
查看>>
java中TCP传输协议
查看>>
STM32 双ADC同步规则采样
查看>>
opencv矩阵运算(2)
查看>>
[js] 如何 在 jQuery 中的 $.each 循环中使用 break 和 continue
查看>>
如何将图片保存至数据库?
查看>>