【发布时间】:2014-05-23 23:42:20
【问题描述】:
我在我的网站上缩放图像,一切正常,但在 IE8 上(在旧版本和新版本上正常工作)图像没有像它们一样缩放 - 我只有图像的左上角。
图像在 Firefox、chrome、ie6、ie7、ie9 等上的显示方式:http://i.imgur.com/jfi6t6A.jpg
以及它在 ie8 上的显示方式:http://i.imgur.com/IAOiVwZ.jpg
我的图片脚本的部分代码:
$('.artykul-tresc p img').each(function() {
var img = this;
var src = $(img).attr('src');
var width = $(img).width() + 'px';
var height = $(img).height() + 'px';
var wm_top = $(img).height() - 38 + 'px';
var alt = $(img).attr('alt');
var replacement = sprintf("<a href=\"%s\" class=\"fancybox\" rel=\"images\"><div style=\"background-image: url('%s'); background-size: cover; width: %s; height: %s; display: inline-block;\"><img src=\"/static/watermark-photo.png\" style=\"position: relative; top: %s; float: right;\" /></div></a>", src, src, width, height, wm_top);
$(img).replaceWith(replacement);
});
并且有来自网站的代码:
<a href="/userfiles/image/sufit-podwieszany-armstrong-2.jpg" class="fancybox" rel="images"><div style="background-image: url('/userfiles/image/sufit-podwieszany-armstrong-2.jpg'); background-size: cover; width: 185px; height: 274px; display: inline-block;"><img src="/static/watermark-photo.png" style="position: relative; top: 236px; float: right;"></div></a>
图像的宽度和高度不是静态的,那么我该如何为 IE8 解决这个问题?
【问题讨论】:
-
我不知道如何将此代码从您的链接放入我的代码中,这将类似于:pastebin.com/mzS7mUqC ?因为这对我不起作用,所以我不知道自己做错了什么。