W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <head> <style> #grad1 { height: 100px; background-image: linear-gradient(0deg, red, blue); } #grad2 { height: 100px; background-image: linear-gradient(90deg, red, blue); } #grad3 { height: 100px; background-image: linear-gradient(180deg, red, blue); } #grad4 { height: 100px; background-image: linear-gradient(-90deg, red, blue); } </style> </head> <body> <h1>线性渐变 - 使用不同的角度</h1> <div id="grad1" style="color:white;text-align:center;">0deg</div><br> <div id="grad2" style="color:white;text-align:center;">90deg</div><br> <div id="grad3" style="color:white;text-align:center;">180deg</div><br> <div id="grad4" style="color:white;text-align:center;">-90deg</div> <p><b>注释:</b>Internet Explorer 9 以及更早的版本不支持渐变。</p> </body> </html>