css 背景色渐变兼容写法
2016-11-17 15:56
453 查看
css3:linear-gradient
比如:黑色渐变到白色,代码如下:
说明:linear-gradient 具体用法。
ie 滤镜:filter
linear-gradient 在 ie9 以下是不支持的,所以对于 ie6 - ie8 我们可以使用滤镜来解决,代码如下:
由于 filter 是 ie 的私有属性,所以我们需要针对 ie9 单独处理滤镜效果,代码如下:
总结:
综上所述,线性渐变的兼容写法如下:
css3:linear-gradient
比如:黑色渐变到白色,代码如下:
.gradient{ 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%); }
说明:linear-gradient 具体用法。
ie 滤镜:filter
linear-gradient 在 ie9 以下是不支持的,所以对于 ie6 - ie8 我们可以使用滤镜来解决,代码如下:
.gradient{ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#ffffff',GradientType=0 ); }
由于 filter 是 ie 的私有属性,所以我们需要针对 ie9 单独处理滤镜效果,代码如下:
:root {filter:none;}
总结:
综上所述,线性渐变的兼容写法如下:
.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 ); } :root .gradient{filter:none;}
相关文章推荐
- css 背景色渐变兼容写法
- CSS背景色渐变写法兼容ie6至ie9
- CSS背景色渐变写法兼容ie6至ie9
- 【css】css 背景色渐变兼容写法
- css 背景色渐变兼容写法
- CSS-背景渐变的兼容写法
- CSS设置DIV背景色渐变显示兼容IE/火狐/谷歌
- css控制背景颜色渐变以及浏览器的兼容写法(转载别人的)
- 全兼容的移动端渐变写法
- 图片垂直居中css写法兼容ie6
- 针对各种浏览器css不兼容的写法
- CSS设置背景色渐变显示
- CSS实现兼容性的渐变背景(gradient)效果兼容众多浏览器
- html背景色渐变(通过CSS实现)
- css 背景色渐变---和背景色透明
- CSS设置DIV背景色渐变显示
- CSS设置DIV背景色渐变显示
- css 背景色半透明 兼容各个浏览器ie6 ie8 火狐
- 背景色渐变兼容最好的方法,兼容IE
- ie6 ie7 ie8 共存以及Firefox浏览器CSS兼容写法