jquery.simplemodal-1.3.3.js :绝对定位(与固定)

发布于 2024-08-19 10:25:39 字数 484 浏览 5 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

想念有你 2024-08-26 10:25:39

尝试将position:absolute添加到特定div区域的实际模态调用中,

如下所示

$("#somebutton").click(function() {

    $('#my-modal-content').modal({
        position:absolute
    });
});

我遇到了与您相同的问题,但我想要为不同的按钮使用不同大小的框/功能,这就是我解决它的方法。

try adding position:absolute to the actual modal call for that particular div region

like below

$("#somebutton").click(function() {

    $('#my-modal-content').modal({
        position:absolute
    });
});

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!

因为看清所以看轻 2024-08-26 10:25:39

这就是我所做的:

jQuery('#MyModal').modal({
    //options
});
jQuery('#MyModal').parents('.simplemodal-container').css('position', 'absolute');

This is what I do:

jQuery('#MyModal').modal({
    //options
});
jQuery('#MyModal').parents('.simplemodal-container').css('position', 'absolute');
不交电费瞎发啥光 2024-08-26 10:25:39

听起来您并不反对根据您的特定需求调整源...因此我建议重新设计它,以便您可以通过选项对象提供定位和溢出属性。

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.

浮生面具三千个 2024-08-26 10:25:39

只需在对话框本身中有一个滚动条即可。

Just have a scrollbar in the dialog itself.

牵你手 2024-08-26 10:25:39

您必须大幅更改代码,尤其是处理 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文