Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript fancybox未居中_Javascript_Fancybox - Fatal编程技术网

Javascript fancybox未居中

Javascript fancybox未居中,javascript,fancybox,Javascript,Fancybox,我使用fancybox 1.3.4在弹出窗口中显示一些内容,但弹出窗口在浏览器中不居中。如何修复它 html代码: <a class="clickMe" title="" message="Last Updated: 10/1/2013">Privacy Policy</a> 隐私政策 js代码: $("body").on("click", ".clickMe", function(){ showAlertSized($(this).attr("title")

我使用fancybox 1.3.4在弹出窗口中显示一些内容,但弹出窗口在浏览器中不居中。如何修复它

html代码:

<a class="clickMe" title="" message="Last Updated: 10/1/2013">Privacy Policy</a>
隐私政策
js代码:

$("body").on("click", ".clickMe", function(){
    showAlertSized($(this).attr("title"), $(this).attr("message"), $(this).attr("width"), $(this).attr("height"));
});
function showAlertSized(title, msg, width, height) {
    debugger;
    if(width === undefined){
        //width = 965;
        width = '95%';
    }
    if(height === undefined) {
        //height = 700;
        height = '95%';
    }
    var content = '<h1>' + title + '</h1>' +
        '<p class="msg">' + msg + '</p>' +
        '<div class="fancy-btns"><input type="button" value="" onclick="closeAlert()" class="fancy-ok-btn" /></div>';
    $.fancybox({
        'content': content,
        'hideOnOverlayClick': false,
        'overlayOpacity' : 0.7,
        'overlayColor' : '#777',
        'width': width,
        'height': height,
        'autoDimensions': false,
        'autoSize': false
    });
}
$(“body”)。在(“click”,“clickMe”,函数()上{
ShowAlertSize($(this.attr)(“title”)、$(this.attr(“message”)、$(this.attr(“width”)、$(this.attr(“height”);
});
功能showAlertSized(标题、消息、宽度、高度){
调试器;
如果(宽度===未定义){
//宽度=965;
宽度='95%';
}
如果(高度===未定义){
//高度=700;
身高='95%';
}
变量内容=“”+标题+“”+
“

”+msg+”

'+ ''; $.fancybox({ “内容”:内容, “HideOnOvercyclick”:false, “产能过剩”:0.7, “套色”:“777”, “宽度”:宽度, “高度”:高度, “自动标注”:false, “自动调整大小”:false }); }
这是截图

您的宽度和高度设置为视口的95%,因此根据逻辑,您有5%的宽度和高度未计算。尝试添加“边距”:在fancybox初始化调用中添加2.5%的边距,这将在fancybox的所有四个面上添加2.5%的边距,使其完全居中。不幸的是,我无法测试这一点或提供一个编码的例子,但理论上它应该工作

你的问题是什么?我们在这里看到的只是一堆代码和一个屏幕截图……请看问题的标题