【问题标题】:Get the Height and width of image if its responsive如果图像响应,则获取图像的高度和宽度
【发布时间】:2017-08-09 08:02:34
【问题描述】:

如果我使用带有“img-responsive”类的img并且没有给出任何高度、宽度、最大高度、最大宽度等,如何在jquery中获取图像的高度和宽度。

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

这是桌面视图

这是移动视图

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

【问题讨论】:

标签: javascript jquery html image crop


【解决方案1】:

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

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

【讨论】:

  • 很高兴我能帮上忙。
猜你喜欢
  • 1970-01-01
  • 2010-11-18
  • 1970-01-01
  • 2013-09-06
  • 1970-01-01
  • 1970-01-01
  • 2017-05-23
  • 2011-11-26
  • 1970-01-01
相关资源
最近更新 更多