700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > css如何让背景色渐变兼容的写法详解

css如何让背景色渐变兼容的写法详解

时间:2018-09-27 16:31:21

相关推荐

css如何让背景色渐变兼容的写法详解

web前端|css教程

css,样式表,写法

web前端-css教程

最近在项目中,有很多地方都用到了线性渐变,比如:表单提交按钮的背景,数据展示的标题背景等等,按照以前的做法是切 1px 图片然后 repeat-x。下面我将介绍如何用 css 来完成该效果。

特效显示网站已经运行了多少天源码,小米平板装ubuntu,爬虫如何避免违法,php回复问题,seo爬虫技术lzw

css3:linear-gradient

php微信推广分享源码,如何打开ubuntu端口,python爬虫职业发展,php study界面,专业seo电话lzw

比如:黑色渐变到白色,代码如下:

婚纱摄影源码下载,制作 vscode 插件,英文版ubuntu怎么关闭,tomcat报错超时,sqlite.鹤夏,wordpress 插件 摘要,web框架前端有哪些,scrapy爬虫的劣势,php ajax请求,百度seo转型做谷歌seo,帝国7.2网站模板,网页制做动画小素才,wordpress 外贸 模板,思创兼职小程序怎么安装lzw

.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;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。