CSS 背景大小在 IE7/8 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15766772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 22:18:03  来源:igfitidea点击:

CSS background-size not working in IE7/8

internet-explorercssinternet-explorer-8internet-explorer-7

提问by Nealv

For some reason my background size is not working in IE 7&8. Can anyone tell me why. Also in the IE inspector, the background-size property is not showing up.

出于某种原因,我的背景大小在 IE 7&8 中不起作用。谁能告诉我为什么。同样在 IE 检查器中,background-size 属性没有显示。

<a href="" class="twitter-custom-follow-button"></a>

.twitter-custom-follow-button {
  float: left;
  width: 96px;
  height: 20px;
  background: url(../img/slices/btns/twitter_follow.png);
  background-size: 96px 20px;
  background-repeat: no-repeat;
}

采纳答案by dsgriffin

That's because background-sizeis a CSS3 property which isn't supportedbefore IE9.

这是因为IE9 之前不支持background-sizeCSS3 属性。

However, there is a thread which suggests a possible workaround: How do I make background-size work in IE?

但是,有一个线程提出了一种可能的解决方法: 如何在 IE 中使背景大小工作?

回答by adrift

IE 7/8 doesn't support the background-sizeproperty .. you will need to use javascript if you want the same functionality

IE 7/8 不支持该background-size属性.. 如果您想要相同的功能,您将需要使用 javascript

回答by Spudley

IE7/8 do not support background-size. It was only introduced in IE9.

IE7/8 不支持background-size。它仅在 IE9 中引入。

If you want to support IE7/8 with this property, you'll need to use a polyfill script for it.

如果你想用这个属性支持 IE7/8,你需要为它使用一个 polyfill 脚本。

The only polyfill I know of that supports background-sizeis CSS3Piev2. Give it a go. (it also adds support for several other CSS features that aren't in old IE versions)

我所知道的唯一支持background-sizepolyfillCSS3Piev2。搏一搏。(它还增加了对旧 IE 版本中没有的其他几个 CSS 功能的支持)

回答by Deepak Singh

use this one code

使用这个代码

 filter:progid:DXImageTransferform.microsoft.AlphaImageLoader(src='img.jpg',sizingMethod='scale')