html - I want the background picture not to be displayed in the IE. How do I do that? -


here's css , , want background picture not displayed in ie . instead want background color displayed. how do that?

html, body {       margin:0;   padding: 0;       background: #a9ac41;   background-image: url("background.png");       background-repeat: no-repeat;   background-size: cover;       margin:0;   padding: 0;      } 

i'm guessing problem here background-size. ie8 , earlier don't support it, you're seeing image messed in ie8 , want solve reverting plain background.

firstly, should tell background-size supported in ie9 , later, don't need blanket change ie versions. need deal lack of support in ie8 , earlier.

here options you:

  • pure css solution:
    can take advantage of way css handles unknown properties provide pure css fallback browsers don't support background-size, specifying size parameter in shorthand background style:

    background: #a9ac41; background: url("bgimage.png") cover; 

    ie8 ignore second background entirely because doesn't understand cover. other browsers ignore first 1 because second 1 overrides it. problem solved: browsers have working background.

  • feature detection solution:
    use tool modernizr test browser support of background-size, , use javascript change page accordingly (eg load different stylesheet if is/isn't supported).

  • filter solution:
    although ie8 doesn't support background-size, possible use -ms-filter property emulate it, degree of success. use code this:

    -ms-filter: "progid:dximagetransform.microsoft.alphaimageloader(src='path_relative_to_the_html_file', sizingmethod='scale')"; 

    example taken mdn

  • polyfill solution:
    there 'polyfill' scripts available implement of missing css features old ie versions, including background-size. in case, 1 i'd recommend css3pie. follow instructions on css3pie site , you'll able use standard background-size in old ie versions.

hope helps.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -