码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-08-24 15:00:01      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:regex   width   flow   down   改变大小   head   query   如何   str   

//树图拉伸
   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边线并左右自适应改变大小?

标签:regex   width   flow   down   改变大小   head   query   如何   str   

原文地址:http://www.cnblogs.com/clj2017/p/7422754.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!