css3属性之background-size兼容ie8方案

版权声明:欢迎转载,转载请标明转载地址 https://blog.csdn.net/u010520146/article/details/86303286
解决方案

在ie8浏览器可能背景图片无法自适应全屏,这时候加入设置filter属性即可解决问题,同时加入height:100

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .bg{
            background: #EAEAEA;
            height: 100%;
            background:url("../img/bg.jpg") no-repeat center center  fixed;
            -webkit-background-size: cover;
            -moz-background-size: cover;
            -o-background-size: cover;
            background-size: cover;
            color: rgba(255,255,255,.95);
            filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/bg.jpg',sizingMethod='scale');
        }
    </style>
</head>
<body class="bg">

</body>
</html>

猜你喜欢

转载自blog.csdn.net/u010520146/article/details/86303286