jquery拖拽改变元素大小

因使用到改变拖拽改变层大小的效果
摘了网上一段,然后自己写的例子

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>层拖拽边框改变大小</title>
<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.9.0/jquery.min.js"></script>
<script>
$(function(){
    var clickX, leftOffset, inx, nextW2, nextW;
    var dragging  = false;
    var doc       = document;
    var labBtn       = $("#wrap").find('#dvSplitter');
    var wrapWidth = $("#wrap").width();

    labBtn.bind('mousedown',function(){
            dragging   = true;
        }
    );

    doc.onmousemove = function(e){
        if (dragging) {
             clickX = e.pageY;             
             labBtn.css("top",clickX+"px");
             var wHegiht=$(window).height();
             labBtn.prev().height((wHegiht-clickX) + 'px');
        }
    };

    $(doc).mouseup(function(e) {
        dragging = false;
        e.cancelBubble = true;
    });
    
    $(".showDetailBtn").off("click").on("click",function(){
       $("#wrap").show();
    });
});
</script>
<style>
#wrap{
    width:100%;
    height:407px;
}
.detailInfoPanel{
    width:100%;
    height:400px;
    background:#f9f9f9;
    position:absolute;
    bottom:0px;
}
 
.frame-main-sptln-tb {
    cursor: row-resize;
    text-align: center;
    height: 3px;
    width:100%;
    border-width: 1px 0;
    position: absolute;
    bottom: 401px;
    right: 0;

}
.frame-main-sptln {
    background-color: #F6F6F6;
    border-style: solid;
    border-color: #D6D6D6;
    line-height: 0;
    font-size: 0;
    z-index: 24;
}
</style>
</head>
<body>             
<button class="showDetailBtn">显示拖拽层</button>
<div id="wrap" style="display:none;">
    <div class="detailInfoPanel"></div>
    <div id="dvSplitter" class="frame-main-sptln frame-main-sptln-tb" style=""></div>
</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值