简体   繁体   English

您可以强制IE8识别背景大小:100%吗?

[英]Can you force IE8 to recognize background-size: 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: 我需要背景图像精灵根据其容器的宽度调整大小,而又不显示整个精灵,而background-size:100%可以做到这一点,就像这样:

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

But, alas, I have to support IE8, which does not support background-size. 但是,a,我必须支持不支持背景尺寸的IE8。 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. 我发现了诸如backgroundSize.js之类的脚本,该脚本强制IE8呈现background-size:cover和background-size:contain,但这些脚本不适用于sprite。 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! 有什么我能做的-考虑到我的绝望,hacky解决方案还可以!

Here is a fiddle of my full code: http://jsfiddle.net/Pw7fL/ 这是我完整代码的小提琴: http : //jsfiddle.net/Pw7fL/

Check out this! 看看这个!

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

As I found out it is easy to use! 我发现它很容易使用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM