如何使用CSS在线性渐变上使用角度

使用linear-gradient()在线性渐变上添加角度。您可以尝试运行以下代码来实现它,以将角度设置为0、90和-90度

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         #demo1 {
            height: 100px;
            background: linear-gradient(0deg, orange, blue);
         }
         #demo2 {
            height: 100px;
            background: linear-gradient(90deg, orange, blue);
         }
         #demo3 {
            height: 100px;
            background: linear-gradient(-90deg, orange, blue);
         }
      </style>
   </head>
   <body>
      <h2>Linear Gradients</h2>
      <div id = "demo1">0 degree</div><br>
      <div id = "demo2">90 degrees</div><br>
      <div id = "demo3">-90 degrees</div>
   </body>
</html>