css3 – 如何使跨浏览器渐变mixin在罗盘,与IE9,IE8,IE7和Opera?

前端之家收集整理的这篇文章主要介绍了css3 – 如何使跨浏览器渐变mixin在罗盘,与IE9,IE8,IE7和Opera?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想为所有浏览器,包括IE9 IE9,IE8,IE7和Opera进行mixin.

http://www.colorzilla.com/gradient-editor/生成代码

它产生

background: #1e5799; /* Old browsers */
/* IE9 SVG,needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzFlNTc5OSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iIzI5ODlkOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUxJSIgc3RvcC1jb2xvcj0iIzIwN2NjYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM3ZGI5ZTgiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top,#1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* FF3.6+ */
background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#1e5799),color-stop(50%,#2989d8),color-stop(51%,#207cca),color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,#7db9e8 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,#7db9e8 100%); /* IE10+ */
background: linear-gradient(top,#7db9e8 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799',endColorstr='#7db9e8',GradientType=0 ); /* IE6-8 */

而对于IE9,我们需要设置filter:none

Support for full multi-stop gradients with IE9 (using SVG). Add a
“gradient” class to all your elements that have a gradient,and add
the following override to your HTML to complete the IE9 support:

06001

Compass具有渐变http://compass-style.org/reference/compass/css3/images/的最新模块,我们可以在调用$experimental-support-for-svg:true之后使用,例如使用像

.gradient {@include linear-gradient(#000000,#ff0000)}

这给出了这样的输出

.gradient {
  background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjUwJSIgeTE9IjAlIiB4Mj0iNTAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2ZmMDAwMCIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==');
  background-size: 100%;
  background-image: -webkit-gradient(linear,50% 0%,50% 100%,#000000),#ff0000));
  background-image: -webkit-linear-gradient(#000000,#ff0000);
  background-image: -moz-linear-gradient(#000000,#ff0000);
  background-image: -o-linear-gradient(#000000,#ff0000);
  background-image: -ms-linear-gradient(#000000,#ff0000);
  background-image: linear-gradient(#000000,#ff0000);
}

如果我们比较compass Image代码这个colorzilla代码

>它的缺失是IE6-8

filter:progid:DXImageTransform.Microsoft.gradient(startColorstr =’#1e5799′,endColorstr =’#7db9e8′,GradientType = 0); / *
IE6-8 * /
>和旧版浏览器背景:#1e5799; / *旧浏览器* /
>而是使用background-image代替background
>它有一个额外的属性background-size:100%;
>并且此页面上没有指令
http://compass-style.org/reference/compass/css3/images/为了如何
解决过滤器:IE9不需要.

我的问题:

>背景大小有什么好处:100%?
>使用背景图像而不是背景有什么好处?
>有没有办法添加过滤器:没有为元素仅为IE9的
罗盘?
>如何在这样的过滤器的指南针中获得IE6-8兼容代码
progid:DXImageTransform.Microsoft.gradient(startColorstr =’#1e5799′,
endColorstr =’#7db9e8′,GradientType = 0);?

解决方法

What is the benefit of background-size: 100%;?

What is the benefit of using background-image instead background?

SVG图像是背景图像,该属性内容是编程生成的图像.为了保持一致,指南针使用背景图像.另外,指定背景图像可以允许编码器指定一个背景颜色,不会被mixin所禁止.

设置背景大小可确保图像实际延伸以填充元素的空间,而不是图像本身的大小.

Is there a way to add filter:none to the element only for IE9 in Compass?

How to get IE6-8 compatible code too in compass like this filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#1e5799′,endColorstr=’#7db9e8′,GradientType=0 );?

这两个选项有三个选项:

>扩展mixin /写你自己的mixin.包含的mixins只是存储在Compass安装位置的文件,因此您可以随时编辑它们,或者使用它们来创建自己的mixins.
> Use CSS3 PIE with Compass.>将IE特定的代码放入一个或多个IE特定的样式表(这是我的首选方法,如果PIE不是一个选项,因为它沙盒CSS,所以你不必做黑客来获得一个版本或另一个忽略给定的CSS行).

原文链接:https://www.f2er.com/css/214592.html

猜你在找的CSS相关文章