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 supportbackground-size, specifying size parameter in shorthandbackgroundstyle:background: #a9ac41; background: url("bgimage.png") cover;ie8 ignore second
backgroundentirely because doesn't understandcover. 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 ofbackground-size, , use javascript change page accordingly (eg load different stylesheet if is/isn't supported).filtersolution:
although ie8 doesn't supportbackground-size, possible use-ms-filterproperty 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, includingbackground-size. in case, 1 i'd recommend css3pie. follow instructions on css3pie site , you'll able use standardbackground-sizein old ie versions.
hope helps.
Comments
Post a Comment