简体   繁体   English

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

[英]jquery.simplemodal-1.3.3.js : absolute positioning (vs. fixed)

I'm using Eric Martin's sweet 'simplemodal' jQuery plugin . 我正在使用Eric Martin的可爱的“简单模式” jQuery插件 It works wonderfully and would recommend it to anyone looking for a lightweight jQuery-based modal dialogue solution. 它的运行效果非常好,它会推荐给任何寻求基于jQuery的轻量级模式对话解决方案的人。

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. 默认情况下,容器元素使用“ overflow:auto”来处理内容太长而无法容纳在浏览器窗口中的内容。 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? 任何人都对如何优雅地进行这项工作有任何想法?

try adding position:absolute to the actual modal call for that particular div region 尝试在特定div区域的实际模式调用中添加position:absolute

like below 像下面

$("#somebutton").click(function() { $(“#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! 祝好运!

This is what I do: 这是我的工作:

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

对话框本身中只有一个滚动条。

听起来您对使源适应您的特定需求没有不利...因此,我建议您对其进行重新加工,以便您可以通过options对象提供定位和溢出属性。

You'd have to change the code significantly, especially the code that deals with IE (IE6 mainly). 您必须对代码进行重大更改,尤其是处理IE(主要是IE6)的代码。

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. 对于某些浏览器,只需将其更改为绝对位置即可,但是某些浏览器或页面大小调整(在任何浏览器中)将恢复为固定位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM