TweenMax实现一个弹出搜索框动画效果代码

代码语言:html

所属分类:搜索

代码描述:TweenMax实现一个弹出搜索框动画效果代码

代码标签: 弹出 搜索 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  <link href="https://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet">
  
  
  
<style>
* {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  box-sizing: border-box;
}

body {
  width: 100%;
  min-height: 100vh;
  background-image: linear-gradient(to right, #4daf54, #3d8880);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "PT Sans", sans-serif;
}

.search {
  width: 450px;
  height: 120px;
  position: relative;
  overflow: hidden;
}
.search-input {
  width: 100%;
  height: 100%;
  padding: 0 65px 25px 60px;
  position: absolute;
  z-index: 1;
  border: none;
  outline: none;
  background-color: rgba(255, 255, 255, 0.15);
  color: #ddd;
  font-size: 28px;
  letter-spacing: 0.3px;
  transform-origin: 10%;
  transform: scaleX(0);
  font-family: "PT Sans", sans-serif;
}
.search-button {
  position: absolute;
  right: 60px;
  bottom: 33px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 3px solid #fff;
  background-color: transparent;
  cursor: pointer;
  outline: none;
  transform: rotate(45deg);
  -webkit-tap-highlight-color: transparent;
}
.search-button::-moz-focus-inner {
  border: 0;
}
.search-label {
  position: absolute;
  top: 0;
  left: 60px;
  width: 325px;
  height: 77px;
  line-height: 95px;
  color: #ddd;
  font-size: 28px;
  letter-spacing: 0.3px;
  pointer-events: none;
  overflow: hidden;
}
.search-label div {
  white-space: pre;
}
.search-border {
  width: 25px;
  height: 3px;
  position: absolute;
  right: 47px;
  bottom: 32px;
  transform: rotate(45deg);
  background-color: #fff;
  cursor: pointer;
}
.search-text {
  opacity: 0;
  pointer-events: none;
}
.search:before {
  content: "";
  position: absolute;
  width: 3px;
  height: 18px;
  left: 40px;
  top: 40px;
  background-color: #fff;
  opacity: 0;
  transition: opacity 0.3s;
}
.search.edge:before {
  opacity: 1;
}
.search-close {
  position: absolute;
  right: 15px;
  top: 5px;
  z-index: 5;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.search-close.visible {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0.4s;
}

input::-ms-clear {
  display: none;
}
</style>


</head>

<body >
  <form class="search">
  <input class="search-input" id="input" type="text" autocomplete="off"/>
  <label class="search-label" for="input"></label>
  <button class="search-button" type="reset"></button>
  <div class="search-border"></div>
  <div class="search-close">x</div>
</form>
 
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/TweenMax.min.js"></script>
      <script >
let search = document.querySelector('.search');
let searchInp = search.children[0];
let searchLbl = search.children[1];
let searchBtn = search.children[2];
let searchBrd = search.children[3];
let searchCls = search.children[4];
let searchTxt, clonedTxt, clonedLbl, clonedLblWrap, animating = false, busy = true;
let TLTxt = new TimelineLite();
let TLSrch = new TimelineLite({onReverseComplete: () => {
  TLTxt.clear();
  animating = false;
}});

createTxt('Enter a search query', searchLbl, 'search-text');
searchTxt = document.querySelectorAll('.search-text');

search.........完整代码请登录后点击上方下载按钮下载查看

网友评论0