tnblog
首页
视频
资源
登录

好看的搜索框

5945人阅读 2019/4/11 1:00 总访问:3467515 评论:1 收藏:0 手机
分类: 前端

直接上代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Document</title>
  8. <link rel="stylesheet" href="css/mystyle.css">
  9. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" />
  10. </head>
  11. <body>
  12. <div class="search-box">
  13. <input class="search-txt" placeholder="Type to search" type="text">
  14. <a class="search-btn" href="#">
  15. <i class="fas fa-search"></i>
  16. </a>
  17. </div>
  18. </body>
  19. </html>

css:

  1. body{
  2. margin0;
  3. padding0;
  4. background-color#0984e3;
  5. }
  6. .search-box{
  7. position: absolute;
  8. top50%;
  9. left50%;
  10. transformtranslate(-50%,-50%);
  11. background-color#2f3640;
  12. height40px;
  13. border-radius40px;
  14. padding10px;
  15. }
  16. /* 特效 */
  17. .search-box:hover > .search-txt{
  18. width240px;
  19. padding0px 6px;
  20. }
  21. .search-box:hover > .search-btn{
  22. background-color: white;
  23. }
  24. .search-btn{
  25. color#e84118;
  26. width40px;
  27. height40px;
  28. background-color#2f3640;
  29. display:flex;
  30. text-decoration: none;
  31. border-radius50%;
  32. /* 左右居中 */
  33. justify-content:center;
  34. /* 上下居中 */
  35. align-items: center;
  36. transition0.4s;
  37. float: right;
  38. }
  39. .search-txt{
  40. background: none;
  41. box-sizing: border-box;
  42. color: white;
  43. border: none;
  44. outline: none;
  45. line-height40px;
  46. font-size16px;
  47. width0px;
  48. transition1s;
  49. float: left;
  50. }

这个来源于b站的一个大佬:

不愿透漏姓名的红领巾大会员

大家有想法的可以去看看他往期的视频!


欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739

评价

饰心

2019/4/11 16:22:42

贴上效果图,更赞

这一世以无限游戏为使命!
排名
2
文章
634
粉丝
44
评论
93
docker中Sware集群与service
尘叶心繁 : 想学呀!我教你呀
一个bug让程序员走上法庭 索赔金额达400亿日元
叼着奶瓶逛酒吧 : 所以说做程序员也要懂点法律知识
.net core 塑形资源
剑轩 : 收藏收藏
映射AutoMapper
剑轩 : 好是好,这个对效率影响大不大哇,效率高不高
ASP.NET Core 服务注册生命周期
剑轩 : http://www.tnblog.net/aojiancc2/article/details/167
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术