本文介绍了检索css3缩放元素的宽度/高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算抵消offsetWidth属性的奇怪(我想)。

这是场景:

I'm fighting against an oddity (I think) of the offsetWidth property.
this is the scenario:

我有,在我的js中,我执行css3转换
到这个元素,例如:

I've got, let's say, a span tag, in my js, at a certain point I perform a css3 transformto this element, like:

        el.set('styles', {
            'transform':'scale('+scale+', '+scale+')',      /* As things would be in a normal world */
            '-ms-transform':'scale('+scale+', '+scale+')',      /* IE 9 */
            '-moz-transform':'scale('+scale+', '+scale+')',         /* Moz */
            '-webkit-transform':'scale('+scale+', '+scale+')',  /* Safari / Chrome */
            '-o-transform':'scale('+scale+')'       /* Oprah Winfrey */
        });
        w = el.getWidth();
        console.log('after scaling: ' + w);

此时,日志返回模糊值,因为它不知道该说什么。 br>
有什么建议吗?

at this point the log returns me fuzzy values, like it doesn't know what to say.
any suggestion?

推荐答案

为我返回正确的值。

getBoundingClientRect() returns the correct values for me.

这篇关于检索css3缩放元素的宽度/高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 22:01
查看更多