在CSS3旋转之后检索元素的正确offsetTop和offsetLeft(Retrieving correct offsetTop and offsetLeft of an element after a CSS3 rotation)
我正在寻找一种方法来在执行变换旋转后获得元素的正确offsetTop / offsetLeft值(或类似值)。
这可能吗? 还有其他我不知道的元素属性吗?
我已经包含了一个可能有助于解释问题的图像。
I'm looking for a way to get correct offsetTop / offsetLeft values (or similar) of an element after performing a transform rotation.
Is this possible? Are there any other element properties which i'm not aware of?
I have included an image which might help in explaining the issue.
原文:https://stackoverflow.com/questions/7287173
更新时间:2019-12-17 15:32
最满意答案
在执行webkit变换动画后,CSS3的奇怪动画不会告诉您更改的位置。
但是,这个链接可能会有所帮助。
谢谢
CSS3's strange animations does not tell you the changed positions after you have performed a webkit transform animation.
However, this link might be of help.
thanks
相关问答
由于元素#contain是溢出元素,因此您可以尝试像这样获取scrollTop: console.log("scroll top:", document.getElementById('contain').scrollTop);
来自MDN: 元素的scrollTop是元素顶部到最顶层可见内容距离的度量。 Element.scrollTop Since the element #contain is the overflow element, you can try get the scroll
...
我想你是对的,说人们不能点击半像素,所以个人来说,我会使用圆整的jQuery偏移量... I think you are right by saying that people cannot click half pixels, so personally, I would use rounded jQuery offset...
在执行webkit变换动画后,CSS3的奇怪动画不会告诉您更改的位置。 但是,这个链接可能会有所帮助。 如何在JavaScript中进行css3转换后获取元素的位置? 谢谢 CSS3's strange animations does not tell you the changed positions after you have performed a webkit transform animation. However, this link might be of help. How do
...
你必须使用一个IIFE,以便当它被点击时,当前迭代的“terrain”将它的属性(offsetLeft,offsetTop)设置为y。 希望这可以帮助: var lands = document.getElementsByClassName('terrain');
for (var i = 0; i < lands.length; i++) {
(function (land) {
land.onclick = function () {
alert('left: '+la
...
你实际上正在缩放画布。 画布是嵌入式的,不会考虑调整绘图功能的外部值,只考虑canvas标签/>本身附带的属性值。 section #canvas {
//Remove width: 800px;
//Remove height: 500px;
display: block;
border: 1px solid black;
margin: 10px auto 0px;
}
做点什么。 canvas.width = 800;
canvas.height = 500;
wind
...
我认为你应该能够做到这一点: HTML some username
jQuery的 jQuery('.get-close-to').hover(function() {
var offset = jQuery(this).css('offset');
alert( 'Left: ' + offset.left + '\nTop: ' + offset.top );
});
I think you s
...
你显然有一个参考jQuery库,所以你为什么不使用它来获得偏移量? 使用jQuery,你不需要任何变量,比如isIE 。 使用库的最大好处是跨浏览器兼容性。 以下是你如何做到这一点... var off = $(parnts[i]).offset();
alert(off.top);
在jQuery API上偏移 You clearly have a reference to the jQuery library, so why aren't you using it to get the o
...
喜欢这个 http://jsfiddle.net/j32t2/4/ CSS - 最初隐藏它 .fixed {
position:fixed;
width:100%;
z-index: 700;
top:0;
display: none;
}
JS - 如果它还没有在那里淡入它 jQuery(function(){
var menuOffset = jQuery('.header-bar')[0].offsetTop;
jQuery(documen
...
如何使用offset方法返回元素的像素偏移量(相对于文档)? var offset = $('input', myTableRow).offset();
// access offset.left and offset.top properties
您可以使用此值将其他元素定位在同一位置: $(myTooltipElement).appendTo(document.body).css(offset)
What about the offset method, which returns the
...
我遇到了jquery rotate,这是一个旋转解决方案,即使在不支持CSS3的IE8中也是如此 请参阅链接了解详情 http://code.google.com/p/jqueryrotate/wiki/Examples I come across jquery rotate which is a solution for rotation even in IE8 which doesn't support CSS3 Please refer link for details http://cod
...