How to resize ONLY horizontally or vertically with jQuery UI Resizable?

前端 未结 7 2276
长情又很酷
长情又很酷 2020-12-12 23:29

The only solution I\'ve found is to set the max and min height or width with the current value.

Example:

foo.resizable({ 
  maxHeight: foo.height(),          


        
7条回答
  •  被撕碎了的回忆
    2020-12-12 23:57

    While the poster was mainly asking for a horizontal-only resize, the question does ask for vertical, too.

    The vertical case has a special issue: You might have set a relative width (e.g. 50%) that you want to keep even when the browser window is resized. However jQuery UI sets an absolute width in px once you first resize the element and the relative width is lost.

    If found the following code to work for this use case:

    $("#resizable").resizable({
        handles: 's',
        stop: function(event, ui) {
            $(this).css("width", '');
       }
    });
    

    See also http://jsfiddle.net/cburgmer/wExtX/ and jQuery UI resizable : auto height when using east handle alone

提交回复
热议问题