如何拖拽DIV边线并左右自适应改变大小?

Posted 浮生

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何拖拽DIV边线并左右自适应改变大小?相关的知识,希望对你有一定的参考价值。

//树图拉伸
   jQuery(function ($){
                 var doc = $(document), dl = $(".side-tree"), dc = $(".tree-content");
                 var sum = dl.css("left") + dc.width() +
                    $(".tree-handler").mousedown (function (e) {
                       var tree = $(this);
                       var deltaX = e.clientX-(parseFloat(tree.css("left")) || parseFloat(tree.prop("clientLeft")));
                       doc.mousemove(function (e){
                          var lt = e.clientX - deltaX;
                          lt = lt < 188 ? 188 : lt;
                          dl.width(lt-86)//目录树宽
                          $(".tree-handler").css("left",dl.width()+42);//拖动把手位置
                          var treeConLeft = $(".tree-handler").css("left");//右侧内容区位置
                          var reg = new RegExp("px","g");
                          treeConLeft = treeConLeft.replace(reg, "");
                          treeConLeft = treeConLeft-26 +"px";
                          $(".tree-content").css("margin-left",treeConLeft)
                       });
                    })
                 doc.mouseup (function(){
                    doc.unbind("mousemove");
                 });
                 doc[0].ondragstart = doc[0].onselectstart = function (){
                    return false;
                 };
              });
});

 

<div class="row tabX" style="position: sticky;overflow-x: hidden">
    <table class="table table-bordered table-hover text-center">
        <thead class="bg-green">
        <tr>
          
        </tr>
        </thead>
    </table>
</div>

以上是关于如何拖拽DIV边线并左右自适应改变大小?的主要内容,如果未能解决你的问题,请参考以下文章

css能不能实现左边div固定宽度,右边div自适应撑满剩下的宽度

抛砖引玉之宽度自适应布局

想用jQuery mobile js 做网页的自适应大小宽度的改变,就是当网页宽度变小时页面还是显示的原来所有内容

怎样用css控制图片自适应大小?

怎样用css控制图片自适应大小?

如何让这个div随屏幕的大小而自适应