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

              
                <div id="navigation-bar" class="clearfix">
  <form id="search" action="/search" method="GET" target="_top">
    <div id="label"><label for="search-terms" id="search-label" class="material-icons">&#xE8B6;</label></div>
    <div id="input"><input type="text" name="q" id="search-terms" placeholder=" Search..."></div>
  </form>
</div>
              
            
!

CSS

              
                #navigation-bar{
  position:relative;
  height:25px;
}

#search{
  position:absolute;
  top:0;
  right:0;
  width:25px;
  height:25px;
}

#label{
  width:25px;
  height:25px;
  position:relative;
  z-index:20;
}

#label label{
  display:block;
  height:25px;
  width:25px;
  color:#ccc;
  cursor:pointer;
}

#label label:hover{
  color:#898989;
}

#input{
  position:absolute;
  top:0;
  right:25px;
  width:150px;
  height:25px;
  z-index:5;
  overflow:hidden;
}

#input input{
  display:block;
  position:absolute;
  top:0;
  right:-150px;
  width:150px;
  height:100%;
  margin-left:10px;
  margin-right:-60px;
  padding-left:0px;
  border:none;
  background-color:#fff;
  font-size:12px;
  backface-visibility:none;
  border-radius:0;
  transition:right 0;
}

#input input:focus{
  outline:none;
}

#input.focus{
  z-index:20;
}

#input.focus input{
  right:0;
  transition:right 0.5s;
}
              
            
!

JS

              
                (function(window){

    // get vars
    var searchEl = document.querySelector("#input");
    var labelEl = document.querySelector("#label");

    // register clicks and toggle classes
    labelEl.addEventListener("click",function(){
        if (classie.has(searchEl,"focus")) {
            classie.remove(searchEl,"focus");
            classie.remove(labelEl,"active");
        } else {
            classie.add(searchEl,"focus");
            classie.add(labelEl,"active");
        }
    });

    // register clicks outisde search box, and toggle correct classes
    document.addEventListener("click",function(e){
        var clickedID = e.target.id;
        if (clickedID != "search-terms" && clickedID != "search-label") {
            if (classie.has(searchEl,"focus")) {
                classie.remove(searchEl,"focus");
                classie.remove(labelEl,"active");
            }
        }
    });
}(window));
              
            
!
999px

Console