How do I make background-size work in IE?

前端 未结 8 2109
无人共我
无人共我 2020-11-22 00:30

Is there any known way to make the CSS style background-size work in IE?

8条回答
  •  死守一世寂寞
    2020-11-22 01:19

    Even later, but this could be usefull too. There is the jQuery-backstretch-plugin you can use as a polyfill for background-size: cover. I guess it must be possible (and fairly simple) to grab the css-background-url property with jQuery and feed it to the jQuery-backstretch plugin. Good practice would be to test for background-size-support with modernizr and use this plugin as a fallback.

    The backstretch-plugin was mentioned on SO here.The jQuery-backstretch-plugin-site is here.

    In similar fashion you could make a jQuery-plugin or script that makes background-size work in your situation (background-size: 100%) and in IE8-. So to answer your question: Yes there is a way but atm there is no plug-and-play solution (ie you have to do some coding yourself).

    (disclaimer: I didn't examine the backstretch-plugin thoroughly but it seems to do the same as background-size: cover)

提交回复
热议问题