I’m generating a bar of horizontal gradient as a background across my site that works perfectly in every browser except…IE9.
The gradient itself is working, it is just that I want to limit the height of the blue bar. Check it out in Safari/Firefox/Chrome and then in IE9 and you can see that the blue gradient fills the entire element.
Horizontal gradient bar using CSS
Here is my CSS:
#inner {
background: #1e5799;
background: -moz-linear-gradient(top, #1e5799 0%, #0057be 35%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(35%,#0057be));
background: -webkit-linear-gradient(top, #1e5799 0%,#0057be 35%);
background: -o-linear-gradient(top, #1e5799 0%,#0057be 35%);
background: -ms-linear-gradient(top, #1e5799 0%,#0057be 35%);
background: linear-gradient(to bottom, #1e5799 0%,#0057be 35%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#0057be',GradientType=0 );
background-size: 1px 10%;
background-repeat: repeat-x;
margin: 0 auto;
padding: 1em 0;
}
This code should work on IE9:
I made it with Visual CSS Gradient Generator
Updated CSS:
IE9 doesn’t support CSS3 gradients, but it supports inline SVG. I don’t recommend to mix up
filterand SVG backgrounds on IE9, i think the best approach is to use conditional comments as explained in this article by Paul Irish.