你可以强制IE8识别背景大小:100%? [英] Can you force IE8 to recognize background-size: 100%?

查看:209
本文介绍了你可以强制IE8识别背景大小:100%?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要背景图片精灵根据其容器的宽度调整大小,而不显示整个精灵和背景大小:100%实现这一点,如下:

I need background image sprites to resize according to the width of their container, without showing the whole sprite, and background-size:100% accomplishes this, like so:

#featured ul.icon-controls li.prevention {
   background:url(img/ico1.png) no-repeat;
   background-size:100%;
   height:60px;
   width:50px; 
   background-position: 0 -113px;
}

但是,唉,我不得不支持IE8,尺寸。我发现了像backgroundSize.js的脚本,它强制IE8渲染background-size:cover和background-size:contain,但是这些不适用于sprite。我需要为每个图标的各种状态使用精灵(悬停/活动/非活动)。

But, alas, I have to support IE8, which does not support background-size. I've found scripts like backgroundSize.js, which force IE8 to render background-size:cover and background-size:contain, but those don't work for sprites. And I need to use a sprite for the various states of each icon (hover/active/inactive).

有什么我可以做的 - 黑客的解决方案是确定的,因为我绝望!

Is there anything I can do -- hacky solutions are ok given my desperation!

是我的完整代码的小提琴: http://jsfiddle.net/Pw7fL/

Here is a fiddle of my full code: http://jsfiddle.net/Pw7fL/


解决方案

推荐答案

/github.com/louisremi/background-size-polyfillrel =nofollow> https://github.com/louisremi/background-size-polyfill

https://github.com/louisremi/background-size-polyfill

我发现它很容易使用!

这篇关于你可以强制IE8识别背景大小:100%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆