javascript nyroModal - 如何配置模态框的宽度和高度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5257645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
nyroModal - how to configure the width and height of the modal box
提问by horgen
I am trying to controll the width and height of the modal window, but I have no idea how to override the default settings.
我正在尝试控制模态窗口的宽度和高度,但我不知道如何覆盖默认设置。
I've been looking at the nmObject (http://nyromodal.nyrodev.com/), but my javascript knowledge is not that great and I have no idea what the correct way to implement this is.
我一直在查看 nmObject ( http://nyromodal.nyrodev.com/),但我的 javascript 知识并不是那么好,我不知道实现它的正确方法是什么。
Here is my attempt, but with a syntax error:
这是我的尝试,但有一个语法错误:
$.nmObj( sizes: { initW: 300, initH: 300 });
What am I doing wrong? :\
我究竟做错了什么?:\
EDIT:
编辑:
$(function() {
$('.nyroModal').nyroModal();
$.nmObj({sizes: { initW: 300, initH: 300 }});
});
No syntax errors atleast, but I don't think im using the function correctly
至少没有语法错误,但我认为我没有正确使用该功能
回答by alexl
try:
尝试:
$.nmObj({sizes: { initW: 300, initH: 300 }});
Hope it helps.
希望能帮助到你。
回答by cyberhobo
Looks like you're using nyroModal v2. For an iframe, you need to set the initial size in the CSS:
看起来您正在使用 nyroModal v2。对于 iframe,您需要在 CSS 中设置初始大小:
.nyroModalCont iframe {
width: 300px;
height: 300px;
}
There's a github issuefor this, which is closed, so I think that's how it will work in this version.
这有一个github 问题,它已关闭,所以我认为这就是它在这个版本中的工作方式。
Ivailo's answer applies to nyroModal v1, I believe.
我相信 Ivailo 的回答适用于 nyroModal v1。
回答by Ivailo Bardarov
Another way of doing it.
另一种方法。
<script type="text/javascript">
$(document).ready(function() {
$.nyroModalSettings({
type: 'iframe',
height: 500,
width: 700,
resizable: true,
autoSizable: true,
titleFromIframe: true,
// modal: true,
// selIndicator: '#loading',
contentLoading: "" // use our own
});
$('a.nyroModalPhotos').nyroModal();
});
</script>
回答by irinal
For this filter
对于这个过滤器
.* Iframe filter
.* iframe 过滤器
.* Before: filters.formFile
.* 之前:filters.formFile
Locate in min.js the file is part of a string
load: function (nm) { nm.store.iframe = $('<iframe />').attr({ src: 'javascript:\'\';', id: 'nyromodal-iframe-' + (new Date().getTime()), frameborder: '0' })
在 min.js 中找到该文件是字符串的一部分
load: function (nm) { nm.store.iframe = $('<iframe />').attr({ src: 'javascript:\'\';', id: 'nyromodal-iframe-' + (new Date().getTime()), frameborder: '0' })
and add
并添加
.css({ height: nm.sizes.h })
the result should be
结果应该是
load: function (nm) { nm.store.iframe = $('<iframe />').attr({ src: 'javascript:\'\';', id: 'nyromodal-iframe-' + (new Date().getTime()), frameborder: '0' }).css({ height: nm.sizes.h })

