1

When I set a CSS property to a float value, like so:

​$('#div').css('left', 123.1234567 );

Inspecting #div in the DOM shows that left was set to 123.1234567px, however all three of these:

console.log($('#div').css('left'), $('#div').position(), $('#div').offset() );

return the integer value of 123px.

Is jQuery trying to be too smart, or is it masking a frailty in the browsers? Do browsers support sub-pixel positioning of divs? Would they if I were using a canvas tag? ​</p>

4

2 回答 2

1

我相信这与 jQuery 中的已知错误有关。请参阅http://bugs.jquery.com/ticket/9628

我对 jQuery 的height().

为什么 jQuery 的 height() 会自动对值进行四舍五入?

于 2014-02-26T13:00:55.260 回答
-1

我不确定您的代码为什么不起作用,我在 JSFiffle 上尝试过的代码似乎运行良好。

http://jsfiddle.net/JBDkr/2/

于 2012-04-27T05:48:11.177 回答