background-image: linear-gradient 属性hover动画

1.效果

2.代码

复制代码
<!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>svg文字动画</title>
  <link rel="stylesheet" href="test.css">
  <style>
    @property --property-color1 {
      syntax: "<color>";
      inherits: false;
      initial-value: yellow;
    }
    @property --property-color2 {
      syntax: "<color>";
      inherits: false;
      initial-value: green;
    }
    :root {
      --a:red;
    }
    #box {
      width: 800px;
      height: 300px;
      margin: 200px auto;
      cursor: pointer;
      color: var(--a);
      background-image: linear-gradient(60deg, var(--property-color1),  var(--property-color2));
      transition: --property-color1 .5s ease-out,--property-color2 .5s ease-out;
    }
    #box:hover {
      --property-color1: green;
      --property-color2: yellow;
    }

    #box2 {
      width: 800px;
      height: 300px;
      margin: 0 auto;
      cursor: pointer;
      background-image: linear-gradient(60deg, yellow,green,green,yellow);
      background-size: 200% 100%;
      background-position: 0% 0%;
      transition: all .4s ease-out;
    }
    #box2:hover {
      background-position: 100% 0%;
    }
  </style>
</head>

<body>
  <div id="app">
    <div id="box">box</div>
    <div id="box2">box2</div>
    <div id="demoCanvas"></div>

    <script>

    </script>
  </div>
</body>

</html>
相关推荐
高心星5 小时前
鸿蒙6.0应用开发——Tabs滑动动画
华为·动画·tabs·鸿蒙6.0·harmonyos6.0
twe77582581 天前
“交织现实与虚拟:CCP-RIE在AR/VR工业动画中的创新展现“
科技·3d·制造·动画
twe775825816 天前
从极限测试到3D动画:揭开CCP-RIE的隐秘面纱
科技·3d·制造·动画
图扑软件19 天前
图扑 HT 帧动画 | 3D 动态渲染设计与实现
前端·javascript·3d·动画·数字孪生
twe775825821 天前
动态揭示CCP-RIE技术中的缺陷形成:从微观机理到3D动画演示
科技·3d·制造·动画
hey2020052824 天前
Houdini渲染农场哪个好用?
动画·blender·maya·3d渲染·houdini·cinema4d
twe775825825 天前
“揭开3D IC封装的神秘面纱:动画演绎芯片堆叠的艺术“
科技·3d·制造·动画
赫尔·普莱蒂科萨·帕塔1 个月前
重构AI漫剧工业化
人工智能·重构·动画·agi
twe77582581 个月前
电镀液应用中的技术支持体系:如何优化工艺并解决常见问题
科技·3d·制造·动画
twe77582581 个月前
3D IC封装的崭新视角:如何用3D动画揭示技术奥秘
科技·3d·制造·动画