IE8兼容background-size

来源:互联网 发布:全球拍软件 编辑:程序博客网 时间:2024/04/29 08:30

因为background-size是CSS3的属性,所以IE8并不支持。

可以采用滤镜来支持,即

在IE不支持这个属性的时候可以通过滤镜来实现这样的一个效果。

代码如下:

<strong>background-image: url('file:///F:/test/images/flashbg.jpg');background-size: cover;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='file:///F:/test/images/flashbg.jpg',  sizingMethod='scale');</strong>

这样就可以让IE也实现background-size:100%100%的效果了,注意这两个路径要一样,并且是绝对路径。


但是需要全路径。



也可以采用

backgroundsize.min.htc, 这个可以在https://github.com/louisremi/background-size-polyfill拷贝或者下载。


body {    height: 100%;    margin: 0;    background: url(images/126.jpg) center no-repeat;    background-size: cover;    -ms-behavior: url(backgroundsize.min.htc);    behavior: url(backgroundsize.min.htc);}
但是需要注意的是此处的
    background-size: cover;需要设置,而且不能用100% 100%等的样式。
这样的样式是chrome与ie都兼容的。

0 0