How to make modal scroll with main page

我与影子孤独终老i 提交于 2019-12-23 09:03:39

问题


I have a modal with the contents taller than the browser height, as a result I have some contents which cannot be displayed. (seems like the modal position is fixed and cannot be scrolled as a whole)

How can I make the modal scrollable with the main page so that I can actually view the contents below?


回答1:


What you could do is set the modal's CSS position to absolute instead of fixed.

To do this, just get the class name of the modal or ID like this and set it to absolute:

.modal {
position: absolute !important;
}

Or, even better, edit the main CSS for your modal (if you can) and change the position from fixed to absolute.

jsFiddle example: http://jsfiddle.net/hUNZs/




回答2:


I've tried <div class="modal myModal"></div>

CSS

.myModal {
      overflow: auto !important; 
      height: 300px; //set a height to a modal so it wont overlapped when the body tag's height is smaller than the modal
}


来源:https://stackoverflow.com/questions/10060541/how-to-make-modal-scroll-with-main-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!