How do I make background-size work in IE?

前端 未结 8 2108
无人共我
无人共我 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:14

    There is a good polyfill for that: louisremi/background-size-polyfill

    To quote the documentation:

    Upload backgroundsize.min.htc to your website, along with the .htaccess that will send the mime-type required by IE (Apache only — it's built in nginx, node and IIS).

    Everywhere you use background-size in your CSS, add a reference to this file.

    .selector { 
        background-size: cover;
        /* The url is relative to the document, not to the css file! */
        /* Prefer absolute urls to avoid confusion. */
        -ms-behavior: url(/backgroundsize.min.htc);
    }
    

提交回复
热议问题