html+css动态搜索框

动态搜索框

代码如下

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>你好,小周</title>
  <link rel="stylesheet" href="style6.css">
</head>
<body>
  <div id="search-box">
    <input class="search-txt" type="text" placeholder="搜索" >
    <a class="search-btn">
      <svg t="1612010397908" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2738" width="64" height="64"><path d="M192 448c0-141.152 114.848-256 256-256s256 114.848 256 256-114.848 256-256 256-256-114.848-256-256z m710.624 409.376l-206.88-206.88A318.784 318.784 0 0 0 768 448c0-176.736-143.264-320-320-320S128 271.264 128 448s143.264 320 320 320a318.784 318.784 0 0 0 202.496-72.256l206.88 206.88 45.248-45.248z" fill="#181818" p-id="2739"></path></svg>
    </a>
  </div>  
</body>
</html>
CSS
/*动态搜索框*/
body{
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family:"monospace";
  background-image: linear-gradient(125deg,#2ecc71,#3498db,#8e44ad,#34495e);
  background-size: 400%;
  animation: change 15s infinite;
}
#search-box{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  background: #424242;
  height: 40px;
  border-radius: 40px;
  padding: 10px;
}
.search-btn{
  color: #e84118;
  float: right;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #424242;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: 0.4s;
}
.search-txt{
  border: none;
  background: none;
  outline: none;
  float: left;
  padding: 0;
  color: white;
  font-size: 16px;
  transition: 0.4s;
  line-height: 40px;
  width: 0;
}
#search-box:hover>.search-txt{
  width: 200px;
  padding: 0 6px;
}
#search-box:hover>.search-btn{
  background: white;
}
@keyframes change{
  0%{
      background-position: 0% 50%;
  }
  50%{
      background-position: 100% 50%;
  }
  100%{
      background-position: 0% 50%;
  }
}

效果展示

在这里插入图片描述

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

涂月十八

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值