CSS 扩展悬停搜索栏

在这里插入图片描述

CSS实现搜索框悬停扩展

      <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>输入框悬浮</title>
<style>
   *{
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: consolas;
   }
   body{
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 100vh;
     background: #cfd1e1;
      overflow: hidden;
   }
   .searchBox{
      position: relative;
      width: 65px;
      height: 50px;
      display: flex;
      justify-content: center;
      align-items: center;
      transition: 0.5s;
   }
   .searchBox:hover{
      width: 400px;
   }
   .searchBox::before{
      content: '';
      position: absolute;
      top:0;
      left: 0;
      width: 10px;
      height: 100%;
      background: linear-gradient(#fff,#fff,#e3e3e3);
      z-index: 1;
      filter: blur(1px);
   }
   .searchBox::after{
      content: '';
      position: absolute;
      top:0;
      right: -1px;
      width: 10px;
      height: 100%;
      background:#9d9d9d;
      z-index: 1;
      filter: blur(1px);
   }
   .shadow{
      position: absolute;
      top:0;
      left: -50px;
      width: calc(100% + 50px);
      height: 300px;
      background: linear-gradient(180deg,rgba(0,0,0,0.1),
      transparent,transparent);
      transform-origin: top;
      transform: skew(45deg);
      pointer-events:none
   }
   .shadow::before{
       content: '';
       position: absolute;
       width: 50px;
       height: 50px;
       background: #cfd1e1;
       z-index:1;
   }
   .searchBox input{
      position: relative;
      width: 100%;
      height: 100%;
      border: none;
      padding: 10px 25px;
      outline: none;
      font-size: 15px;
      color: #555;
      background: linear-gradient(#dbdae1,#a3aaba);
      box-shadow: 5px 5px 5px rgba(0,0,0,0.1),
      15px 15px 15px rgba(0,0,0,0.1),
      20px 20px 15px rgba(0,0,0,0.1),
      30px 30px 15px rgba(0,0,0,0.1),
      inset 1px 1px 2px #fff
   }
   .searchBox input::placeholder,
   .searchBox input
   {
       color: transparent;
   }
   .searchBox:hover input::placeholder,
   .searchBox:hover input
   {
     color:#555
   }
   ion-icon{
        position: absolute;
        right: 25px;
   }
</style>
</head>
<body>
<div class="searchBox">
     <div class="shadow"></div>
	   <input type="text" placeholder="Search Anything You Want...">
     <ion-icon name="search-outline"></ion-icon>
</div>
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
</body>
</html>
// 另外不知道咋么使用<ion-icon>这个标签图标的小伙伴请移步菜鸟了解=====>
https://www.runoob.com/ionic/ionic-icon.htmlhttps://www.runoob.com/ionic/ionic-icon.html
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

代码De搬运工

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

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

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

打赏作者

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

抵扣说明:

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

余额充值