jquery.simplemodal-1.3.3.js :绝对定位(与固定)
我正在使用 Eric Martin 的甜蜜“simplemodal”jQuery 插件。它工作得非常好,并且会推荐给任何正在寻找基于 jQuery 的轻量级模态对话解决方案的人。
也就是说,我有一些特别长的内容“需要”显示为模式。默认情况下,容器元素使用“overflow:auto”来处理太长而无法容纳在浏览器窗口中的内容。这在大多数情况下效果很好,但在这种情况下,我希望对话保持全高并与页面的其余部分一起滚动(定位“绝对”与“固定”)。我可以通过将源中的任何 position: 'fixed' 引用修改为 position: 'absolute' 来相当轻松地完成此工作,但这很糟糕,因为这意味着我的所有模态都会显示这样...
有人对如何优雅地完成这项工作有任何想法吗?
I'm using Eric Martin's sweet 'simplemodal' jQuery plugin. It works wonderfully and would recommend it to anyone looking for a lightweight jQuery-based modal dialogue solution.
That said, I have some particularly long content that "needs" to be displayed as a modal. By default, the container element uses 'overflow:auto' to handle content that is too long to fit within the browser window. This works well in most cases, but in this case I would like the dialogue to remain full height and scroll with the rest of the page (positioned 'absolute' vs. 'fixed'). I can get this working fairly easily by modifying any position: 'fixed' references in the source to position: 'absolute' but this sucks as it means ALL my modals will display this way...
Anyone have any thoughts on how to make this work gracefully?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试将position:absolute添加到特定div区域的实际模态调用中,
如下所示
$("#somebutton").click(function() {
我遇到了与您相同的问题,但我想要为不同的按钮使用不同大小的框/功能,这就是我解决它的方法。
try adding position:absolute to the actual modal call for that particular div region
like below
$("#somebutton").click(function() {
I had the same issue as you, but I wanted a different size box for different buttons/functions and this is how I solved it. Good Luck!
这就是我所做的:
This is what I do:
听起来您并不反对根据您的特定需求调整源...因此我建议重新设计它,以便您可以通过选项对象提供定位和溢出属性。
It sounds like youre not adverse to adapting the source to you specific needs... therefore i would recommend reworking it so that you can supply the positioning and overflow properties via an options object.
只需在对话框本身中有一个滚动条即可。
Just have a scrollbar in the dialog itself.
您必须大幅更改代码,尤其是处理 IE 的代码(主要是 IE6)。
仅更改为绝对位置最初适用于某些浏览器,但某些浏览器或页面调整大小(在任何浏览器中)将恢复到固定位置。
You'd have to change the code significantly, especially the code that deals with IE (IE6 mainly).
Just changing to an absolute position would work initially for certain browsers, but some browsers or a page resize (in any browser) would revert back to a fixed position.