灵活宽度居中模态窗口
有谁知道有一种方法可以让模态窗口弹出窗口具有灵活的宽度(例如屏幕宽度的%),并且始终居中,至少在调用它时是这样。
我准备用 js/jQuery 自己编写这个代码(通过一个可以发送最小宽度、百分比和最大宽度的函数),但我想知道预制的解决方案以避免重新发明轮子(特别是如果它们没有带来繁琐的框架)。
现在我在 Windows 上使用 jqModal,我喜欢它的简单性
Does anyone know of a way to have a modal window pop-up that can have a flexible width (say % of the screen width) that is always centered, at least when it's invoked.
I am about to code this myself in js/jQuery (via a function that you can send min-width, percentage, and max width to), but it I'm wondering about pre-made solutions to avoid re-inventing the wheel (especially if they don't arrive with cumbersome frameworks).
Right now I'm using jqModal for the windows and I like it for its simplicity
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过 jquery 模式选项
对话框的宽度(以像素为单位)。
http://jqueryui.com/demos/dialog/#option-width
Did you try jquery modal options
The width of the dialog, in pixels.
http://jqueryui.com/demos/dialog/#option-width
这是我设计的一种方法,用于创建具有您描述的所有功能的流体模式,而且作为奖励,它在 95% 的情况下甚至不需要任何 JavaScript,只需要 HTML 和 CSS! - http://www .backalleycoder.com/2011/11/16/best-damn-modal-method-period%E2%84%A2/ - 下面我粘贴了它使用的 HTML 和 CSS,博客文章包含更长、更详细的解释和现场演示。
HTML 结构:
您需要的 CSS:
Here's a method I devised to create fluid modals with all the features you described, and as a bonus, it doesn't even require any JavaScript in 95% of cases, just HTML and CSS! - http://www.backalleycoder.com/2011/11/16/best-damn-modal-method-period%E2%84%A2/ - below I have pasted the HTML and CSS it uses, the blog post contains a much longer, more detailed explanation and a live demo.
The HTML structure:
The CSS you'll need: