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>
相关推荐
twe77582585 天前
用3D动画揭示技术路线的多样性
科技·3d·制造·动画
LqKKsNUdXlA9 天前
多通道卷积神经网络 变压器 故障诊断 MATLAB (附赠变压器振动信号数据集) 关键词
动画
twe775825814 天前
参数调控与3D动画的互动魅力
科技·3d·制造·动画
twe775825817 天前
用3D动画解密3D IC封装中的微观世界
科技·3d·制造·动画
_风华ts22 天前
创建并使用AimOffset
ue5·动画·虚幻·虚幻引擎·aimoffset
hudawei99622 天前
flutter和Android动画的对比
android·flutter·动画
hudawei99623 天前
TweenAnimationBuilder和AnimatedBuilder两种动画的比较
flutter·ui·动画·tweenanimation·animatedbuilder
xiangxiongfly9151 个月前
Android 共享元素转场效果
android·动画·共享元素转场效果
儿歌八万首2 个月前
Jetpack Compose 动画实战:让你的 UI 动起来
android·kotlin·动画·compose
weixin_465790912 个月前
混合储能系统容量优化:基于粒子群算法的Matlab实现
动画