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>
<!DOCTYPE html><html><head> <title>嵌入式设备登录</title> <link rel="stylesheet" type="text/css" href="style.css"></head><body> <div class="login-box"> <img src="background.jpg" class="background"> <h1>设备登录</h1> <form> <label for="username">用户名:</label> <input type="text" id="username" name="username" required> <label for="password">密码:</label> <input type="password" id="password" name="password" required> <input type="submit" value="登录"> </form> </div></body></html>body { background-color: #f2f2f2;}.login-box { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); background-color: #fff; padding: 50px; border-radius: 10px; box-shadow: 0 0 20px 0 rgba(0,0,0,0.2);}.background { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; filter: blur(5px);}h1 { margin: 0 0 30px; padding: 0; font-size: 28px; text-align: center; color: #333; text-shadow: 2px 2px 2px rgba(0,0,0,0.2);}form { display: flex; flex-direction: column;}label { margin-bottom: 10px; font-size: 18px; color: #333; text-shadow: 2px 2px 2px rgba(0,0,0,0.2);}input[type="text"], input[type="password"] { padding: 10px; border: none; border-radius: 5px; background-color: #f2f2f2; color: #333; box-shadow: inset 0 0 5px rgba(0,0,0,0.2);}input[type="submit"] { margin-top: 20px; padding: 10px; border: none; border-radius: 5px; background-color: #f90; background-image: linear-gradient(to bottom, #f90, #f60); color: #fff; font-size: 18px; cursor: pointer; box-shadow: 0 2px 2px rgba(0,0,0,0.2);}input[type="submit"]:hover { background-image: linear-gradient(to bottom, #f60, #f90);}合并以上代码
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值