Well, an absolutely positioned element that is set at (0,0) will ALWAYS got to the (0,0) corner of its closest parent element that is position relative. This is the defined behavior and cannot be altered.
Since you are absolutely positioning the modal, I'd suggest pulling out out of the relatively positioned element and just sticking it under either (a) a non-positioned parent, or (b) just after the body tag.
发布评论
评论(3)
在大多数情况下,您的模式应该是正文的直接子级。
如果模态的祖先具有相对或绝对定位,则除了更改有问题的元素上的样式之外,您无法“撤消”这种操作。
HTML:
CSS:
In most cases, your modal should be a direct child of the body.
If the modal has an ancestor with relative or absolute positioning, you cannot "undo" that short of changing the style on the offending element.
HTML:
CSS:
我们很想先看到您的代码,但您可能正在寻找以下内容:
We would love to see your code first, but probably you're looking nto this:
那么,设置在 (0,0) 的绝对定位元素将始终到达其最近的相对位置父元素的 (0,0) 角。这是定义的行为,无法更改。
由于您绝对定位模态,因此我建议从相对定位的元素中取出并将其粘贴在(a)非定位父级或(b)主体标签之后。
编辑:乔纳森打败了我!
Well, an absolutely positioned element that is set at (0,0) will ALWAYS got to the (0,0) corner of its closest parent element that is position relative. This is the defined behavior and cannot be altered.
Since you are absolutely positioning the modal, I'd suggest pulling out out of the relatively positioned element and just sticking it under either (a) a non-positioned parent, or (b) just after the body tag.
EDIT: Johnathan beat me to it!