>  기사  >  웹 프론트엔드  >  兼容低版本IE浏览器的背景颜色渐变效果_html/css_WEB-ITnose

兼容低版本IE浏览器的背景颜色渐变效果_html/css_WEB-ITnose

WBOY
WBOY원래의
2016-06-24 11:29:191164검색

兼容低版本IE浏览器的背景颜色渐变效果:
大多数的兼容性问题都是由于低版本的IE浏览器所导致的,本章节分享一段代码实例,它能够实现背景的颜色的渐变效果,如果在标准浏览器中直接采用css3属性即可实现,但是IE低版本的问题所以需要进行一下兼容性处理。
代码如下:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">.gradient{  background:#000000;  background:-moz-linear-gradient(top, #000000 0%, #ffffff 100%);  background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #000000), color-stop(100%, #ffffff));  background:-webkit-linear-gradient(top, #000000 0%, #ffffff 100%);  background:-o-linear-gradient(top, #000000 0%, #ffffff 100%);  background:-ms-linear-gradient(top, #000000 0%, #ffffff 100%);  background:linear-gradient(to bottom, #000000 0%, #ffffff 100%);  filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000',endColorstr='#ffffff',GradientType=0);  width:300px;  height:100px;  margin:0px auto;}:root .gradient{filter:none;}</style></head><body><div class="gradient"></div></body></html>

上面的代码实现了我们的要求,标准浏览器使用的linear-gradient属性,而低版本的IE浏览器则是使用的滤镜效果。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=14244

更多内容可以参阅:http://www.softwhy.com/divcss/

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.