【问题标题】:JQuery3 Dialog inside of an iframe positioniframe位置内的JQuery3对话框
【发布时间】:2021-06-15 22:11:47
【问题描述】:

我正在尝试在 iframe 中打开一个对话框。 当我将位置设置为:

   position: { my: 'center', at: 'center', of: window }

它指的是 iframe 的窗口。 这需要我在 iframe 很长时滚动。 我尝试使用:

  position: {my: "center", at: "center", of: window.top}

但我收到了这个错误:

jquery.min.js:3 Uncaught TypeError: Cannot read property 'defaultView' of undefined
    at La (jquery.min.js:3)
    at Ma (jquery.min.js:3)
    at Function.css (jquery.min.js:3)
    at Object.get (jquery.min.js:3)
    at Function.css (jquery.min.js:3)
    at jquery.min.js:4
    at S (jquery.min.js:3)
    at jQuery.fn.init.r.fn.<computed> [as outerWidth] (jquery.min.js:4)
    at d (jquery-ui.custom.min.js:formatted:614)
    at jQuery.fn.init.e.fn.position (jquery-ui.custom.min.js:formatted:666)

【问题讨论】:

标签: jquery jquery-ui iframe modal-dialog position


【解决方案1】:

您可以考虑以下几点:

position: { my: 'center', at: 'top', of: window }

请看:https://api.jqueryui.com/position/

at 部分可以使用水平和垂直元素。

定义目标元素上的哪个位置对齐定位的元素:“水平垂直”对齐。有关可能值的完整详细信息,请参阅my 选项。百分比偏移量是相对于目标元素的。

查看my 定义时,它说:

定义要定位的元素上的哪个位置与目标元素对齐:“水平垂直”对齐。 "right" 等单个值将被规范化为 "right center""top" 将被规范化为 "center top"(遵循 CSS 约定)。可接受的水平值:"left""center""right"。可接受的垂直值:"top""center""bottom"。示例:"left top""center center"。每个维度还可以包含偏移量,以像素或百分比为单位,例如,"right+10 top-25%"。百分比偏移量是相对于被定位的元素的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-06
    • 1970-01-01
    相关资源
    最近更新 更多