Edit This Code:
See Result »
<!DOCTYPE html> <html> <head> <style> #grad1 { height: 200px; background: -webkit-linear-gradient(red, yellow, green); /* For Safari 5.1 to 6.0 */ background: -o-linear-gradient(red, yellow, green); /* For Opera 11.1 to 12.0 */ background: -moz-linear-gradient(red, yellow, green); /* For Firefox 3.6 to 15 */ background: linear-gradient(red, yellow, green); /* Standard syntax (must be last) */ } #grad2 { height: 200px; background: -webkit-linear-gradient(red, orange, yellow, green, blue, indigo, violet); /* For Safari 5.1 to 6.0 */ background: -o-linear-gradient(red, orange, yellow, green, blue, indigo, violet); /* For Opera 11.1 to 12.0 */ background: -moz-linear-gradient(red, orange, yellow, green, blue, indigo, violet); /* For Firefox 3.6 to 15 */ background: linear-gradient(red, orange, yellow, green, blue, indigo, violet); /* Standard syntax (must be last) */ } #grad3 { height: 200px; background: -webkit-linear-gradient(red 10%, green 85%, blue 90%); /* For Safari 5.1 to 6.0 */ background: -o-linear-gradient(red 10%, green 85%, blue 90%); /* For Opera 11.1 to 12.0 */ background: -moz-linear-gradient(red 10%, green 85%, blue 90%); /* For Firefox 3.6 to 15 */ background: linear-gradient(red 10%, green 85%, blue 90%); /* Standard syntax (must be last) */ } </style> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?73c27e26f610eb3c9f3feb0c75b03925"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </head> <body> <h3>3 Color Stops (evenly spaced)</h3> <div id="grad1"></div> <h3>7 Color Stops (evenly spaced)</h3> <div id="grad2"></div> <h3>3 Color Stops (not evenly spaced)</h3> <div id="grad3"></div> <p><strong>Note:</strong> Color stops are automatically spaced evenly when no percents are specified.</p> <p><strong>Note:</strong> Internet Explorer 9 and earlier versions do not support gradients.</p> </body> </html>
Result: