CSS – Linear Gradient with cross browser compatibility.
The Source Code to copy/paste:
1 2 3 4 5 6 7 8 | .gradient { /* Vertical Gradient Sample */ background-color : #444444 ; /* Oldest Browsers with no gradient compatibility */ background-image : -webkit-gradient(linear, left top , left bottom , from( #444444 ), to( #999999 )); /* Chrome, Safari 4+ */ background-image : -webkit-linear-gradient( top , #444444 , #999999 ); /* Chrome 10-25, iOS 5+, Safari 5.1+ */ background-image : -moz-linear-gradient( top , #444444 , #999999 ); /* Firefox 3.6-15 */ background-image : -o-linear-gradient( top , #444444 , #999999 ); /* Opera 11.10-12.00 */ background-image : linear-gradient(to bottom , #444444 , #999999 ); /* Chrome 26, Firefox 16+, IE 10+, Opera 12.10+ */ } |
If you want IE 6-9 compatibility:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <style type= "text/css" > .gradient { /* Horizontal Gradient Sample */ background : #ffffff ; /* Old browsers */ /* IE9 SVG, needs conditional override of 'filter' to 'none' */ background : url (data:image/svg+xml;base 64 ,PD 94 bWwgdmVyc 2 lvbj 0 iMS 4 wIiA/Pgo 8 c 3 ZnIHhtbG 5 zPSJodHRwOi 8 vd 3 d 3 LnczLm 9 yZy 8 yMDAwL 3 N 2 ZyIgd 2 lkdGg 9 IjEwMCUiIGhlaWdodD 0 iMTAwJSIgdmlld 0 JveD 0 iMCAwIDEgMSIgcHJlc 2 VydmVBc 3 BlY 3 RSYXRpbz 0 ibm 9 uZSI+CiAgPGxpbmVhckdyYWRpZW 50 IGlkPSJncmFkLXVjZ 2 ctZ 2 VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ 1 c 2 VyU 3 BhY 2 VPblVzZSIgeDE 9 IjAlIiB 5 MT 0 iMCUiIHgyPSIxMDAlIiB 5 Mj 0 iMCUiPgogICAgPHN 0 b 3 Agb 2 Zmc 2 V 0 PSIwJSIgc 3 RvcC 1 jb 2 xvcj 0 iI 2 ZmZmZmZiIgc 3 RvcC 1 vcGFjaXR 5 PSIxIi 8 +CiAgICA 8 c 3 RvcCBvZmZzZXQ 9 IjEwMCUiIHN 0 b 3 AtY 29 sb 3 I 9 IiMwMDAwMDAiIHN 0 b 3 Atb 3 BhY 2 l 0 eT 0 iMSIvPgogIDwvbGluZWFyR 3 JhZGllbnQ+CiAgPHJlY 3 QgeD 0 iMCIgeT 0 iMCIgd 2 lkdGg 9 IjEiIGhlaWdodD 0 iMSIgZmlsbD 0 idXJsKCNncmFkLXVjZ 2 ctZ 2 VuZXJhdGVkKSIgLz 4 KPC 9 zdmc+); background : -moz-linear-gradient( left , #ffffff 0% , #000000 100% ); /* FF3.6+ */ background : -webkit-gradient(linear, left top , right top , color-stop( 0% , #ffffff ), color-stop( 100% , #000000 )); /* Chrome, Safari4+ */ background : -webkit-linear-gradient( left , #ffffff 0% , #000000 100% ); /* Chrome10+, Safari5.1+ */ background : -o-linear-gradient( left , #ffffff 0% , #000000 100% ); /* Opera 11.10+ */ background : -ms-linear-gradient( left , #ffffff 0% , #000000 100% ); /* IE10+ */ background : linear-gradient( left , #ffffff 0% , #000000 100% ); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr= '#ffffff' , endColorstr= '#000000' ,GradientType= 1 ); /* IE6-8 */ } </style> <!--[if gte IE 9 ]> <style type= "text/css" > .gradient { filter: progid:dximagetransform.microsoft.gradient(enabled=false); } </style> <![endif]--> |
IE 6-9 compatibility code can creates conflicts with some JavaScript Libraries.