javascript “位置:固定” div 在父旋转或平移时不固定
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9364203/
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
"position: fixed" div is not fixed when parent rotates or translates
提问by viebel
A div
with "position: fixed"
is embedded into a parent div
. When the parent rotates or translates, the child div
moves also.
阿div
与"position: fixed"
被嵌入到一个父div
。当父对象旋转或平移时,子对象div
也会移动。
Is it a bug? I expected the child div
to remain fixed.
这是一个错误吗?我希望孩子div
保持不动。
HTML snippet:
HTML 片段:
<div id="mask">
<div id="page">
</div>
</div>
See a repro at: http://jsfiddle.net/PseKK/
请参阅以下网址的重现:http: //jsfiddle.net/PseKK/
I know that I can fix it by applying the reverse transformation to the child div
but for performance reasons in my real scenario, I am looking for a solution that doesn't involve extra-transformation.
我知道我可以通过对孩子应用逆向转换来解决它,div
但出于我实际场景中的性能原因,我正在寻找一种不涉及额外转换的解决方案。
Any idea how to overcome?
知道如何克服吗?
采纳答案by JimmyBanks
This is a repost, the answer is located in this original question
这是转帖,答案位于这个原始问题中
Positions fixed doesn't work when using -webkit-transform
使用 -webkit-transform 时,位置固定不起作用
Unfortunately it is a bug, but there seems to be a way to get around it.
不幸的是,这是一个错误,但似乎有办法绕过它。