最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Making Bootstrap modal resizable with jQuery UI issue - Stack Overflow

programmeradmin3浏览0评论

So I have a Bootstrap modal I've created and I am trying to make it resizable using jquery. I have the resize working horizontally but if you try to resize vertically its like the content inside of the modal is not contained within the element I am trying to resize.

I tried using the 'alsoResize' property on the .resizable() and included all the divs within the modal but that seems to cause other issues.

$('.modal-content').resizable({
    alsoResize: ".modal-header, .modal-body, .modal-footer"
});

Here is my example: /

So I have a Bootstrap modal I've created and I am trying to make it resizable using jquery. I have the resize working horizontally but if you try to resize vertically its like the content inside of the modal is not contained within the element I am trying to resize.

I tried using the 'alsoResize' property on the .resizable() and included all the divs within the modal but that seems to cause other issues.

$('.modal-content').resizable({
    alsoResize: ".modal-header, .modal-body, .modal-footer"
});

Here is my example: https://jsfiddle.net/p7o2mkg4/

Share Improve this question edited Oct 6, 2015 at 15:52 Lemon Kazi 3,3112 gold badges40 silver badges71 bronze badges asked Oct 6, 2015 at 15:23 user3618473user3618473 2281 gold badge3 silver badges8 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 12

You actually did everything right! But the default overflow behaviour of HTML elements is visible. So if the parent element's content gets overflowed, they break out of the modal and that doesn't look good! So, you need to set the CSS overflow property to scroll or hidden to fix breaking on small size. Try adding:

.modal-content.ui-resizable {
  overflow: scroll;
}

This will ensure scrolling on overflow of the element.

Link to JSFiddle: https://jsfiddle.net/p7o2mkg4/1/

This works (css)

#myModal>div{
overflow-y: hidden;
overflow-x: hidden;
}

In case anyone stumbles across this like I have, make sure you have both jQueryUI.js and jQueryUI.css.

I thought having only jQueryUI.js was enough, but it turns out adding the stylesheet is why it wasn't working for me.

发布评论

评论列表(0)

  1. 暂无评论