%form.search
  .search__wrapper
    %input.search__field{:type => "text", :name => "", :placeholder => "Search for..."}
    %button.fa.fa-search.search__icon{:type => "submit"}
View Compiled
$icon-size: 50px;
$main-color: #e9f1f4;


// STYLE TO WRAP UP THE DEMO
.search {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  * {
    outline: none;
    box-sizing: border-box;
  }
}

// SEARCH FIELD
.search__wrapper {
  position: relative;
}
.search__field {
  width: $icon-size;
  height: $icon-size;
  color: transparent;
  font-family: Lato, sans-serif;
  font-size: 1.35em;
  padding: .35em ($icon-size) .35em 0;
  border: 1px solid transparent;
  border-radius: 0;
  cursor: pointer;
  -webkit-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  &:focus {
    border-bottom-color: #ccc;
    width: 50vw;
    color: #2b2b2b;
    cursor: default;
    ~ .search__icon {
      background-color: transparent;
      cursor: pointer;
      pointer-events: auto;
    }
  }
}
.search__icon {
  position: absolute;
  top: 0;
  right: 0;
  background-color: $main-color;
  width: $icon-size;
  height: $icon-size;
  font-size: 1.35em;
  text-align: center;
  border-color: transparent;
  border-radius: 50%;
  pointer-events: none;
  display: inline-block;
  -webkit-transition: background-color 0.2s ease-in-out;
  transition: background-color 0.2s ease-in-out;
}


// FIELD LABELING
.search__field {
  &::-webkit-input-placeholder, 
  &:-moz-placeholder, 
  &::-moz-placeholder, 
  &:-ms-input-placeholder {
    position: relative;
    top: 0;
    left: 0;
    -webkit-transition-property: top, color;
    transition-property: top, color;
    -webkit-transition-duration: .1s;
    transition-duration: .1s;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
  }
  
  &::-webkit-input-placeholder[style*=hidden], 
  &:-moz-placeholder[style*=hidden], 
  &::-moz-placeholder[style*=hidden], 
  &:-ms-input-placeholder[style*=hidden] {
    color: darken($main-color, 30%);
    font-size: .65em;
    font-weight: normal;
    top: -(round($icon-size / 2.5));
    opacity: 1;
    visibility: visible !important;
  }
}

View Compiled

External CSS

  1. https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css

External JavaScript

This Pen doesn't use any external JavaScript resources.