background-size not working in IE

2019-08-07 03:57发布

问题:

I have checked the other post. I am having some problem in using css3 property background-size in IE.

.topBar {
    width:100%;
    background:url(../siteImages/top_bar.png) repeat-x ;
    background-size:auto 43px;
    height:77px;
}

I know about this code for IE.

filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
src='images/logo.gif',
sizingMethod='scale');

-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(
src='images/logo.gif',
sizingMethod='scale')";

This will make the size of background to cover the area.

回答1:

background-size is a CSS3 property which isn't supported on IE8 and below.

You can also try this:

background:url(../siteImages/top_bar.png) 0 0 / auto 43px repeat-x fixed;


回答2:

try to add vendor

/* Vendor Prefixes used with the Cover Value*/
-webkit-background-size: auto 43px;
-moz-background-size: auto 43px;
-o-background-size: auto 43px;
background-size: auto 43px;

also check this

IE8 fix for background-size property? Retina Image

and this

https://developer.mozilla.org/en-US/docs/Web/CSS/background-size



回答3:

background-size is a CSS3 property which isn't supported before IE9.

However, there is a topic which gives possible solution: How do I make background-size work in IE?