获得缩放图像的高度 [英] Getting height of scaled image
问题描述
我获得图片的原始尺寸。通过 max-width:473px;
应用到图像,并且浏览器自动调整高度。但是内部图像加载事件
我得到原始的,非缩放的大小。
I'm getting original sizes of an image. There is css applied to an image via max-width:473px;
and height is resized automatically by the browser. But inside image load event
i'm getting original, non-scaled sizes.
506x337
之后,css规则映像变为 473x315
。如何在加载事件中获得
315px
高度?
So basically original image sizes were 506x337
and after css rule image becomes 473x315
. How do i get 315px
height inside load event
?
更新
有用于测试的代码段:
http://jsfiddle.net/CXNan/
There is the snippet for testing: http://jsfiddle.net/CXNan/
推荐答案
您也可以使用
this.offsetHeight
b $ b
请参阅小提琴。它包含只读像素大小,请参见参考。它在MSIE中受支持,应该是跨浏览器可靠的。
see the fiddle. It contains read-only pixel size, see the reference. It is supported in MSIE and should be cross-browser reliable.
这篇关于获得缩放图像的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!