使用Dialog API for Office Online设置对话框的恒定大小 [英] Set constant size of dialog box using Dialog API for Office Online

查看:75
本文介绍了使用Dialog API for Office Online设置对话框的恒定大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用

Is there a way to set a constant size for the dialog box that is opened using the Dialog API, by using the min-width/max-width CSS properties or otherwise? The API only allows setting the width and height percentage, which makes the box look inconsistent when resizing or using different resolutions (30% of 1024px is a skinny window, but looks fine for 1920 for example).

我注意到"Office加载项"商店弹出窗口似乎具有最小宽度/最大宽度,因此,在调整大小时,它可以保持一致的外观,我希望可以利用它的功能也是

I noticed that the "Office Add-ins" store pop up seems to have a min-width/max-width, so that when resizing it maintains a consistent look, and I'm hoping that I can leverage what it does as well.

推荐答案

在这里:

var dim = pixelToPercentage(700, 350);
Office.context.ui.displayDialogAsync(window.location.origin + "/pop-ups/create_export_link.html",
                { height: dim.height, width: dim.width },
                createExportLinkCallback);

,支持功能为:

function pixelToPercentage(heightInPixel, widthInPixel) {
    var height = Math.floor(100 * heightInPixel / screen.height);
    var width = Math.floor(100 * widthInPixel / screen.width);
    return { height: height, width: width };
}

通过这种方式,您可以动态地以百分比格式计算尺寸.

this way you calculate the dimensions in the percentage format dynamically.

这篇关于使用Dialog API for Office Online设置对话框的恒定大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆