7_渐变色.html 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. .box{
  9. width: 200px;
  10. height: 200px;
  11. /* background-color: red; */
  12. margin: 100px auto;
  13. /* 线性渐变色 linear-gradient */
  14. /* 语法:linear-gradient(角度,颜色1,颜色2,颜色3,....) */
  15. /* background-image: linear-gradient(red,blue,yellow,green); */
  16. /* 角度:0deg 从左到右渐变 */
  17. /* background-image: linear-gradient(45deg,red,blue); */
  18. /* top left right bottom */
  19. /* to left 从右到左渐变 to right 从左到右渐变 .... */
  20. /* background-image: linear-gradient(to top left,red,blue); */
  21. /* 径向渐变色 radial-gradient */
  22. /* 语法:radial-gradient(颜色1,颜色2,颜色3,....) */
  23. background-image: radial-gradient(red,blue);
  24. /* 径向渐变色默认从中心开始渐变 */
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div class="box"></div>
  30. </body>
  31. </html>