700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > css 背景色渐变兼容写法【HTML】

css 背景色渐变兼容写法【HTML】

时间:2023-04-30 13:43:00

相关推荐

css 背景色渐变兼容写法【HTML】

web前端|html教程

css 背景色渐变兼容写法

web前端-html教程

css3:linear-gradient

714网贷源码,ubuntu怎么杀进程,爬虫for循环遍历,apahce启用php,seo工具seocnmlzw

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

jsp工资管理系统源码,vscode如何看文件夹,ubuntu 鼠标退出,tomcat8 安装,网页爬虫detect,星外主机 php,麒麟seo平台有什么用,dede 获取网站标题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%);}

php网站源码,vscode注释,ubuntu软件,运行tomcat,安装sqlite,上海网页设计,phalcon数据库操作,免备案服务器,隐藏翻页插件,app前端框架,图片爬虫,php5下载,宁波seo优化,springboot整合quartz,a标签 table,制作网站软件,网页元素,cms模板,phpv9后台成空白,给ecshop网站加密码页面,人事管理系统毕业论文,企业程序lzw

说明: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;}

PS:

在实际的项目中,往往会碰到圆角和渐变的组合,如果使用上面的写法,那么在 ie9 下会有 bug(在 ie9 下背景色不能完全切完),解决方法是SVG,具体点此查看。

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