Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compass background-image(linear-gradient) not working on IE

This gradient done using SASS and Compass does not work in any version of Internet Explorer:

@include background-image(linear-gradient(left, rgba(241,236,236,0.95), rgba(241,236,236,0.9), rgba(241,236,236,0.85), rgba(241,236,236,0.8), rgba(241,236,236,0.75), rgba(241,236,236,0.4)));

It translates to this CSS:

  background-image: -webkit-gradient(linear, 0% 50%, 100% 50%, color-stop(0%, rgba(241, 236, 236, 0.95)), color-stop(20%, rgba(241, 236, 236, 0.9)), color-stop(40%, rgba(241, 236, 236, 0.85)), color-stop(60%, rgba(241, 236, 236, 0.8)), color-stop(80%, rgba(241, 236, 236, 0.75)), color-stop(100%, rgba(241, 236, 236, 0.4)));
  background-image: -webkit-linear-gradient(left, rgba(241, 236, 236, 0.95), rgba(241, 236, 236, 0.9), rgba(241, 236, 236, 0.85), rgba(241, 236, 236, 0.8), rgba(241, 236, 236, 0.75), rgba(241, 236, 236, 0.4));
  background-image: -moz-linear-gradient(left, rgba(241, 236, 236, 0.95), rgba(241, 236, 236, 0.9), rgba(241, 236, 236, 0.85), rgba(241, 236, 236, 0.8), rgba(241, 236, 236, 0.75), rgba(241, 236, 236, 0.4));
  background-image: -o-linear-gradient(left, rgba(241, 236, 236, 0.95), rgba(241, 236, 236, 0.9), rgba(241, 236, 236, 0.85), rgba(241, 236, 236, 0.8), rgba(241, 236, 236, 0.75), rgba(241, 236, 236, 0.4));
  background-image: linear-gradient(left, rgba(241, 236, 236, 0.95), rgba(241, 236, 236, 0.9), rgba(241, 236, 236, 0.85), rgba(241, 236, 236, 0.8), rgba(241, 236, 236, 0.75), rgba(241, 236, 236, 0.4));

So what do you do to solve this with IE?

I'm testting it with internet explorer 11. I need it to work from IE9+

As helped below I found for now the answer to cover IE10+, this helped me:

background: -ms-linear-gradient(left, rgba(241,236,236,0.95), rgba(241,236,236,0.9), rgba(241,236,236,0.85), rgba(241,236,236,0.8), rgba(241,236,236,0.75), rgba(241,236,236,0.4)); /* IE10+ */

After I tried the following for IE9 but did not work:

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f1ecec', endColorstr='#fffafa',GradientType=1 );

What can I use to cover annoying IE9?

like image 467
Daniel Ramirez-Escudero Avatar asked Nov 15 '13 09:11

Daniel Ramirez-Escudero


2 Answers

You have to use a filter for IE6-9 that looks like:

filter: progid:DXImageTransform.Microsoft.gradient(...)

and for IE10+

-ms-linear-gradient

I believe IE6-9 may only support 2 color stops. The best thing i can give you too help is this:

http://www.colorzilla.com/gradient-editor/

Amazing tool for this stuff :)

If you "import" your css into the tool you get:

/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2YxZWNlYyIgc3RvcC1vcGFjaXR5PSIwLjk1Ii8+CiAgICA8c3RvcCBvZmZzZXQ9IjgwJSIgc3RvcC1jb2xvcj0iI2YxZWNlYyIgc3RvcC1vcGFjaXR5PSIwLjc1Ii8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmMWVjZWMiIHN0b3Atb3BhY2l0eT0iMC40Ii8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, rgba(241,236,236,0.95) 0%, rgba(241,236,236,0.75) 80%, rgba(241,236,236,0.4) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(241,236,236,0.95)), color-stop(80%,rgba(241,236,236,0.75)), color-stop(100%,rgba(241,236,236,0.4))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(241,236,236,0.95) 0%,rgba(241,236,236,0.75) 80%,rgba(241,236,236,0.4) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(241,236,236,0.95) 0%,rgba(241,236,236,0.75) 80%,rgba(241,236,236,0.4) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(241,236,236,0.95) 0%,rgba(241,236,236,0.75) 80%,rgba(241,236,236,0.4) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(241,236,236,0.95) 0%,rgba(241,236,236,0.75) 80%,rgba(241,236,236,0.4) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f2f1ecec', endColorstr='#66f1ecec',GradientType=0 ); /* IE6-8 */

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:

<!--[if gte IE 9]>
  <style type="text/css">
    .gradient {
       filter: none;
    }
  </style>
<![endif]-->

... or even the SCSS version

// needs latest Compass, add '@import "compass"' to your scss
@include filter-gradient(#f2f1ecec, #66f1ecec, vertical); // IE6-8
// IE9 SVG, needs conditional override of 'filter' to 'none'
$experimental-support-for-svg: true;
@include background-image(linear-gradient(top,  rgba(241,236,236,0.95) 0%,rgba(241,236,236,0.75) 80%,rgba(241,236,236,0.4) 100%));

Heres a link to your imported css which should help you: http://www.colorzilla.com/gradient-editor/#f1ecec+0,f1ecec+100&0.95+0,0.75+80,0.4+100;Custom

like image 183
Lee Avatar answered Nov 14 '22 21:11

Lee


This dont work in IE11

background-image: linear-gradient(top, #ff0000,#ffff00);

This work and show like then webkit version

background-image: linear-gradient(180deg, #ff0000,#ffff00);

The webkit also support the ...deg mode, but dont work as the explorer does, this is the equivalent in webkit.

-webkit-linear-gradient(270deg, #ff0000,#ffff00);

Note: Chrome understand the no webkit version as explorer does.

like image 2
user3589298 Avatar answered Nov 14 '22 21:11

user3589298