6

Linear gradient works fine for all browsers except IE8.
I added progid:DXImageTransform.Microsoft.gradient...this did give it some gradient however expected result is different.
Code:-

div{
height:500px;width:500px; 
background-size: 50px 50px;
background-color: #DDEEEE;
background-image: -webkit-linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);
background-image: -moz-linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);
background-image: -ms-linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);
background-image: -o-linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);
background-image: linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#DDEEEE',GradientType=0 );}    

How do I make this gradient linear?

smons
  • 455
  • 2
  • 6
  • 17

1 Answers1

5

The css I use to create a linear gradient is as follows. Works fine in IE8 too. Seems the only difference to yours is I set a gradientType to 1 (horizontal), not 0 (vertical), and I use distinct colours.

html

<div></div>

css

div{width:400px;height:200px;
    /*gradient background color */
    background: #0071a0; /* Old browsers */
    background: -moz-linear-gradient(left,  #0071a0 1%, #ff0000 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, right top, color-stop(1%,#0071a0), color-stop(100%,#ff0000)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(left,  #0071a0 1%,#00a3ca 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(left,  #0071a0 1%,#ff0000 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(left,  #0071a0 1%,#ff0000 100%); /* IE10+ */
    background: linear-gradient(to right,  #0071a0 1%,#ff0000 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0071a0', endColorstr='#ff0000',GradientType=1 ); /* IE6-9 */
    }

http://jsfiddle.net/yAxbJ/

The other issue is that you are using close to white colours, so the gradient effect isnt that noticeable. Try changing to a more distinct starting colour such as #ff000 to see if the gradient is actually working first. Also you have a duplicate background-color value.

lukeocom
  • 3,243
  • 3
  • 18
  • 30
  • Thanks Luke for pointing out my redundant background-color value it has been edited now, however I can't get to set the gradientType to 1 in your fiddle. Moreover I am using background-image instead of background. Is there anything else I can try? – smons Jun 17 '13 at 04:46
  • the gradientType simply changes the direction of the gradient in IE - http://jsfiddle.net/yAxbJ/1/ - background is a shorthand for all the background properties. background-image should be used specifically for an image, ie background-image:url('image.jpg'); see here - http://stackoverflow.com/questions/10205464/whats-the-difference-between-specifying-background-vs-background-color-in – lukeocom Jun 17 '13 at 07:12
  • I dont have any further suggestions of what to try. The code I provided before should be working for you in IE8... – lukeocom Jun 17 '13 at 07:13
  • 1
    `filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0071a0', endColorstr='#ff0000',GradientType=1 ); /* IE6-9 */` is a real gem. – S. Dixon Oct 15 '14 at 18:51