W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <head> <style> #grad1 { height: 200px; background-color: red; /* 针对不支持渐变的浏览器 */ background-image: linear-gradient(red, yellow, green); } #grad2 { height: 200px; background-color: red; /* 针对不支持渐变的浏览器 */ background-image: linear-gradient(red, orange, yellow, green, blue, indigo, violet); } #grad3 { height: 200px; background-color: red; /* 针对不支持渐变的浏览器 */ background-image: linear-gradient(red 10%, green 85%, blue 90%); } </style> </head> <body> <h1>线性渐变 - 多个色标</h1> <p><b>注释:</b>如果不规定百分百,则会均匀分布色标。</p> <h2>三个色标 (evenly spaced):</h2> <div id="grad1"></div> <h2>七个色标 (evenly spaced):</h2> <div id="grad2"></div> <h2>三个色标 (not evenly spaced):</h2> <div id="grad3"></div> </body> </html>