css基礎---徑向漸變(放射漸變)
阿新 • • 發佈:2021-07-06
radial-gradient() 函式建立一個<image>,用來展示由原點(漸變中心)輻射開的顏色漸變
-預設均勻分佈
radial-gradient(red,blue);
-不均勻分佈
radial-gradient(red 50%,blue 70%);
-改變漸變的形狀
radial-gradient(circle ,red,blue)
circle
ellipse(預設為橢圓)
-漸變形狀的大小
radial-gradient(closest-corner circle ,red,blue)
closest-side 最近邊
farthest-side 最遠邊
closest-corner 最近角
farthest-corner 最遠角(預設值)
-改變圓心
radial-gradient(closest-corner circle at 10px 10px,red,blue);
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .wrap{ height: 500px; width: 800px; margin: 0 auto; background: radial-gradient(closest-corner circle at 80px 80px,red 10%,yellow 50%,green 80%); } </style> </head> <body> <div class="wrap"> </div> </body> </html>