如果图像响应,则获取图像的高度和宽度

Get the Height and width of image if its responsive

如果我将 img 与 class "img-responsive" 一起使用并且没有给出任何高度、宽度、最大高度、最大高度,如何在 jquery 中获取图像的高度和宽度宽度等

我不想要我们可以从 getHeight 和 getWidth 获得的图像的真实高度和宽度,但我想要我能够看到的确切高度和宽度,就像在移动浏览器中我看到的一样小高度和宽度,在台式机或笔记本电脑中更大的高度和宽度。

这是桌面视图

这是移动视图

我想知道我的屏幕有多少像素被该图像覆盖。

您可以使用 jQuery 来完成此操作:

$(window).resize(function(){
    var imgWidth = $('.yourImage').width();
    var imgHeight = $('.yourImage').height();
});