【问题标题】:IE8 background-size: coverIE8背景尺寸:封面
【发布时间】: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 解决这个问题?

【问题讨论】:

标签: css internet-explorer-8


【解决方案1】:

如果您可以使用 jQuery 来解决此问题,那么https://github.com/pakcheong/jqthumb 可能会为您提供帮助。该插件旨在解决IE6、IE7和IE8中的背景覆盖问题。

【讨论】:

    猜你喜欢
    • 2016-02-26
    • 1970-01-01
    • 1970-01-01
    • 2017-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-19
    相关资源
    最近更新 更多