W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <head> <style> #grad1 { height: 150px; width: 200px; background-color: red; /* 针对不支持渐变的浏览器 */ background-image: radial-gradient(red, yellow, green); } #grad2 { height: 150px; width: 200px; background-color: red; /* 针对不支持渐变的浏览器 */ background-image: radial-gradient(circle, red, yellow, green); } </style> </head> <body> <h1>径向渐变 - 形状</h1> <h2>椭圆(默认):</h2> <div id="grad1"></div> <h2>圆:</h2> <div id="grad2"></div> </body> </html>