Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <link href="https://fonts.googleapis.com/css?family=Dosis" rel="stylesheet">
<body>
  <div id="cont">
    <div id="button">
      <div id="tag1" class="tag tag-hide">
        <span id="tagText">search</span>
      </div>
      <form>
        <input id="searchBar" class="search search-hidden"/>
      </form>
      <svg id="magShape" width="280px" height="120px">
        <path id="magBar" class="circ" d="M 120 60 C 120 71, 129 80, 140 80 C 151 80, 160 71, 160 60 C 160 49, 151 40, 140 40 C 129 40, 120 49, 120 60 M 160 60 l 28 0">
          <animate
                   id="circ2Rect"
                   fill="freeze"
                   begin="indefinite"
                   attributeName="d"
                   dur="750ms"
                   to="M 40 80 C 40 80, 240 80, 240 80 C 240 80, 240 40, 240 40 C 240 40, 40 40, 40 40 C 40 40, 40 80, 40 80 M 240 40 l 29 -29"
                   keyTimes="0; 1"
                   calcMode="spline"
                   keySplines=".67,0,.33,1;"
          />
          <animate
                   id="rect2Circ"
                   fill="freeze"
                   begin="indefinite"
                   attributeName="d"
                   dur="450ms"
                   to="M 120 60 C 120 71, 129 80, 140 80 C 151 80, 160 71, 160 60 C 160 49, 151 40, 140 40 C 129 40, 120 49, 120 60 M 160 60 l 28 0"
                   keyTimes="0; 1"
                   calcMode="spline"
                   keySplines=".67,0,.33,1;"
          />
        </path>
      </svg>
    </div>
</body>
              
            
!

CSS

              
                * {
  font-family: 'Dosis', sans-serif;
  font-weight: 100;
}

body {
  background: #333;
}

#cont {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  padding-top: .5em;
  margin: auto;
  width: 40%;
  min-width: 300px;
  max-width: 500px;
  height: 120px;
  border: 3px solid #335599;
  background: #222;
  box-shadow: 0 3px 4px rgba(0,0,0,.3);
}

#button {
  position: relative;
  vertical-align: middle;
  width: 280px;
  height: 120px;
  margin: auto;
}

svg {
  position: absolute;
  background: none;
  border: none;
  outline: none;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  margin: auto;
}

#magShape {
  pointer-events: none;
}

#magBar {
  stroke: #DDD;
  stroke-width: 2;
  fill: none;
  transform-origin: 140px;
  pointer-events: all;
  cursor: pointer;
}

#magBar.circ {
  transform: rotate(45deg) translate(-5px, -6px);
  transition: transform .45s cubic-bezier(.75,0,.8,1);
}

#magBar.rect {
  transform: rotate(0deg);
  transition: transform .75s;
  pointer-events: none;
}

.tag {
  position: relative;
  font-size: 1em;
  color: #FFF;
  top: 11px;
  float: right;
  right: 11px;
  padding: 1px 36px 1px 2px;
  background: #ff4032; /* Old browsers */
  background: -moz-linear-gradient(-30deg, #ff4032 0%, #ff00bf 100%); /* FF3.6-15 */
  background: -webkit-linear-gradient(-30deg, #ff4032 0%,#ff00bf 100%); /* Chrome10-25,Safari5.1-6 */
  background: linear-gradient(120deg, #ff4032 0%,#ff00bf 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff4032', endColorstr='#ff00bf',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
  overflow: hidden;
  cursor: pointer;
  transition: max-width .75s cubic-bezier(.75,0,.25,1), padding .75s cubic-bezier(.75,0,.25,1);
  max-width: 75px;
  text-transform: uppercase;
}

.tag-hide {
  max-width: 0px;
  padding: 1px 0;
  transition: max-width .3s cubic-bezier(.75,0,.25,1), padding .3s cubic-bezier(.75,0,.25,1);
}

.tag-go {
  max-width: 280px;
  padding: 1px 200px 1px 2px;
  transition: max-width .75s cubic-bezier(.75,0,.25,1), padding .75s cubic-bezier(.75,0,.25,1);
}

.tag-done {
  max-width: 0px;
  padding: 1px 0;
  transition: max-width .8s cubic-bezier(.75,0,.25,1), padding .8s cubic-bezier(.75,0,.25,1);
}

.tag:before {
  content: "";
  position: absolute;
  right: 0px;
  width: 0;
  height: 0;
  border: 24px solid transparent;
  border-right-color: #222;
}


.search {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  color: #FFF;
  background: none;
  border: none;
  outline: none;
  font-size: 1.5em;
  vertical-align: middle;
  box-sizing: border-box;
  height: 40px;
  width: 200px;
  border-radius: 0%;
  padding: 0px 6px;
  cursor: text;
  transition: width 1s cubic-bezier(.8,0,.2,1), border-radius .75s ease, padding 1s ease, transform .5s ease;
}

.search-hidden {
  padding: 2px 20px;
  width: 40px;
  border-radius:50%;
  cursor: pointer;
  transition: width .75s cubic-bezier(.5,0,.5,1), border-radius .75s ease, padding 1s ease, transform .5s ease;
}

.search-go {
  width: 200px;
  max-width: 200px;
  border-radius: 0%;
  padding: 0px 6px;
  cursor: text;
  font-size: 1em;
  transform: translate(28px, -38px);
  transition: width 1s cubic-bezier(.8,0,.2,1), border-radius .75s ease, padding 1s ease, transform .5s ease;
}

.search-done {
  max-width: 0px;
  padding: 0px;
  transform: translate(115px, -38px);
  transition: max-width .75s cubic-bezier(.75,0,.25,1), border-radius .75s ease, padding .8s ease, transform .75s cubic-bezier(.75,0,.25,1);
}
              
            
!

JS

              
                // circ: M 100 40 C 100 50, 110 60, 120 60 C 130 60, 140 50, 140 40 C 140 30, 130 20, 120 20 C 110 20, 100 30, 100 40
// rect: M 40 80 C 40 80, 240 80, 240 80 C 240 80, 240 40, 240 40 C 240 40, 40 40, 40 40 C 40 40, 40 80, 40 80 M 240 40 l 28 -28

var magBar = document.getElementById('magBar'),
    circToRect = document.getElementById('circ2Rect'),
    searchBar = document.getElementById('searchBar'),
    rectToCirc = document.getElementById('rect2Circ'),
    tagDx = document.getElementById('tag1'),
    tagText = document.getElementById('tagText'),
    magShape = document.getElementById('magShape'),
    a = searchBar.value,
    exp = 0,
    expandWaitTime,
    collapseWaitTime,
    searchWaitTime;

magBar.onclick = expand;
tagDx.onclick = gosearch;

searchBar.onkeypress = function(e) {
  if (e.which == 13 || e.keyCode == 13) {
    e.preventDefault();
    gosearch();
  }
  return true;
};

searchBar.onblur = collapse;

function expand() {
  searchBar.focus();
  if (exp != 1) {
    exp = 1;
    clearTimeout(collapseWaitTime);
    searchBar.classList.remove('search-hidden');
    circToRect.beginElement();
    magBar.classList.add('rect');
    magBar.classList.remove('circ');
    expandWaitTime = setTimeout(function(){
      tagDx.classList.remove('tag-hide');
    }, 600);
  };
};

function collapse(){
  collapseWaitTime = setTimeout(function(){
    tagDx.classList.add('tag-hide');
    exp = 0;
    clearTimeout(expandWaitTime);
    setTimeout(function(){
      searchBar.classList.add('search-hidden');
      rectToCirc.beginElement();
      magBar.classList.add('circ');
      magBar.classList.remove('rect');
      }, 180);
  }, 150);
};

function gosearch() {
  console.log(searchBar.value);
  clearTimeout(collapseWaitTime);
  searchBar.focus();
  if (searchBar.value!=""){
    tagDx.classList.add('tag-go');
    setTimeout(function(){
      searchBar.classList.add('search-go');
      tagText.innerHTML = "Search:";
    }, 450);
    setTimeout(function(){
      searchBar.classList.add('search-done');
      tagDx.classList.remove('tag-go');
      tagDx.classList.add('tag-done');
    }, 1000);
    setTimeout(function(){
      //location.reload();
    }, 2000);
  };
};
              
            
!
999px

Console