ie6,ie7,ie8下对css background-size并不支持,那么如何在IE6、IE7、IE8下兼容 background-size 呢?
在ie下把图片完整的居中显示在一定范围内
在css中添加如下代码:
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.5imoban.net/uploads/allimg/160622/0ZH35063-0.jpg',sizingMethod='scale');下面给出完整的实例代码:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>让IE兼容background-size的方法</title> <style> .bgpic{background-image: url('http://www.5imoban.net/uploads/allimg/160622/0ZH35063-0.jpg'); background-size: cover; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader( src='http://www.5imoban.net/uploads/allimg/160622/0ZH35063-0.jpg', sizingMethod='scale');} </style> </head> <body> <div class="bgpic" style="width:200px;height:100px;"></div> </body> </html>
IE显示效果如下: