Linear-gradient and browser compatibility

Asked

Viewed 309 times

1

I’m using the following background css in a menu:

background: -webkit-linear-gradient(left, #0260a9, #444); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(left, #0260a9, #444); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(left, #0260a9, #444); /* For Firefox 3.6 to 15 */
background: linear-gradient(left, #0260a9, #444); /* Standard syntax */  

However, in browsers (like IE) that it does not work, the menu is left without background. I wonder if it is possible to add an optional color if the browser does not understand this property, as if it were a default background color.
I know I have two options: make the property compatible with all or add this second color solid option. How to act?

  • 1

    PS: Does not work in versions older than 10, in recent versions works normally. In Edge also.

1 answer

3


For the old browsers, you just set a background solid, without the gradient, thus:

background: #444; //ou outra cor que você queira
background: -webkit-linear-gradient(left, #0260a9, #444);
background: -moz-linear-gradient(left, #0260a9, #444);
background: -o-linear-gradient(left, #0260a9, #444);
background: linear-gradient(to right, #0260a9, #444);

But it all depends on the specifications and audience you will reach. In my work, I hardly care about old browsers, because my clients always work with more modern things, so 'go back' and worry about these 'fix' is not feasible for my case.

  • 1

    Perfect answer! Really, the structure is and should be quite relative to the target audience that your work should reach. Thank you, I hope you help other people. ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.