开发者

jQuery modal window scroll bar

开发者 https://www.devze.com 2023-04-12 05:30 出处:网络
Sorry if you think I didn\'t show you the code because I ha开发者_如何学Pythonven\'t implement yet.

Sorry if you think I didn't show you the code because I ha开发者_如何学Pythonven't implement yet.

I am trying to built a jQuery photo view plugin, but normally when I find some examples on line, the height of the modal window is either the window height which is the height of your computer screen of the document height which is the height of the html body.

When I saw the facebook photo view plugin, the height of the modal window can be extended according to its content height, anyone could tell me how to do that, if you could show me a bit of coding related or some examples would be great, thank you for your great help.


Facebook does something really interesting with their modals. They have the page wrapped in a container, and the modal is added to the DOM as a sibling, rather than a child of the container. So, they set the container to position:fixed instead of the modal. This allows the user to scroll as they normally would if the modal grows past the constraints of their window size.

If you intend to follow the same strategy, the modal will naturally grow as its content does, since your modal doesn't have to be postion:absolute.

Otherwise, this can of course be done with the traditional approach of making the modal position:absolute or position:fixed, but it is a little trickier.

If you have control over the code that is changing the content in the modal, I would evaluate the size of the content and resize/reposition the modal to compensate.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号