How to set background image in html that work in I

2019-09-06 17:48发布

This question already has an answer here:

The following css code is not working in internet explorer.. Please suggest me the solution that work in internet explorer to set background

body {
background: url("images/Login-BG.png") no-repeat center center fixed;

-moz-background-size: cover;

-webkit-background-size: cover;

-o-background-size: cover;

background-size: cover;
}

2条回答
该账号已被封号
2楼-- · 2019-09-06 17:58

Older version of IE don't support background-size: if you need to use a fall back for older version of IE do this:

body {
/* ie fallbacks */
background-image: url(images/Login-BG.png);
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/Login-BG.png', sizingMethod='scale')";

/* desired styles */
background: url("images/Login-BG.png") no-repeat center center fixed;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
查看更多
够拽才男人
3楼-- · 2019-09-06 18:06

For your code to work you need to have height to your body which may be equal to the height of your image.

body {
    background: url("images/Login-BG.png") no-repeat center center fixed;

    -moz-background-size: cover;

    -webkit-background-size: cover;

    -o-background-size: cover;

    background-size: cover;
    height: 265px; /* considering that 265 is the image height */
}
查看更多
登录 后发表回答