<!-- Load icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="container">
  <h1 class="heading">Tiny Animated search bar</h1>
  <div class="searchInputWrapper">
    <input class="searchInput" type="text" placeholder='focus here to search'>
    <i class="searchInputIcon fa fa-search"></i>
    </input>
  </div>
</div>
/* Quick and dirty normalize hax */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: #eee;
  color: #a1a1a1;
  font-family: sans-serif;
}

.container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.heading {
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
}

.searchInputWrapper {
  position: relative;
}

.searchInput {
  width: 20rem;
  height: 2rem;
  padding: 0 1rem; 
  border-radius: 2rem;
  border: none;
  transition: transform 0.1s ease-in-out;
}

::placeholder {
  color: #a1a1a1;
}

/* hide the placeholder text on focus */
:focus::placeholder {
  text-indent: -999px
}

.searchInput:focus {
  outline: none;
  transform: scale(1.1);
  transition: all 0.1s ease-in-out;
}

.searchInputIcon {
  position: absolute;
  right: 0.8rem;
  top: 0.5rem;
  color: #a1a1a1;
  transition: all 0.1s ease-in-out;
}

.container:focus-within > 
.searchInputWrapper > .searchInputIcon {
  right: 0.2rem;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.