cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div id="wrap">
  <div class="center">
    <div class="aside">
      <h3>Emoji Search Bar by <a href="http://lashandias.com/" target="_blank">Lashan Dias</a></h3>
      <p>Try typing in the two phrases:</p>
      <p>
        "directions to the nearest"<br/>
        "directions to make the best".</p>
    </div>

    <div id="search">
      <span class="ac ac-hidden"></span>
      <input type="text">
      <button id="emoji">Search</button>
    </div>
  </div>
</div>



            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Karla);

$body-font: 'Karla', sans-serif;
$head-font: 'Karla', sans-serif;

body {
  background: #f2f2f2;
  height: 100vh;
  position: relative;
  font-family: $body-font;
  cursor: default;
}

::selection {
  background: transparent;
}

input::selection {
  color: #2d2d2d; 
  background: rgba(#5EDF9E, 0.5);
}

a {
  text-decoration: none;
  color: #009dff;
}

/*#wrap {
  width: 800px;
  height: 600px;
  background: #f2f2f2;
  position: relative;
  margin: 60px auto;
}*/

.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#search {
  position: relative;

  input, .ac {
    line-height: 20px;
    font-size: 20px;
    font-family: $body-font;
    font-weight: normal;
    letter-spacing: 0em; 
  }

  input {
    border: 0px;
    padding: 25px;
    padding-right: 100px;
    width: 350px;
    display: block;
    position: relative;
    transition: all 0.3s cubic-bezier(.55,0,.1,1);

    &:focus {
      outline: none;
      
      + button {
        right: -20px;
      }
    }
  }

  .ac {
    z-index: 1;
    position: absolute;
    left: 25px;
    top: 50%;
    transform: translateY(-50%);
    /* margin-top: 1px; */
    opacity: 0.3;
    pointer-events: none;
    transition: 0.3s cubic-bezier(.55,0,.1,1) all;

    &.ac-hidden {
      opacity: 0;
    }
  }

  button {
    cursor: pointer;
    font-family: $head-font;
    font-size: 16px;
    color: white;
    background: #5EDF9E;
    border: 0px;
    padding: 10px 30px;
    line-height: 20px;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translate(25%, -50%);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(.55,0,.1,1);

    &.emoji-bank:after {
      content: "💰";
    }

    &.emoji-pizza:after {
      content: "🍕";
    }

    &.emoji {
      &:before { left: -100% }
      &:after { opacity: 1; left: 0; }
    }

    &:after,
    &:before {    
      position: absolute;
      background: #5EDF9E;
      color: white;
      width: 100%;
      height: 100%;
      top: 0;
      line-height: 40px;
      transition: 0.3s cubic-bezier(.55,0,.1,1) all;
      opacity: 0;
    }

    &:before {
      content: "Search";
      opacity: 1;
      left: 0;
    }

    &:after {
      content: "";
      left: 100%;
      font-size: 21px;
      line-height: 40px;
    }

    &:hover {

      &:after, &:before {
        background: darken(#5EDF9E, 20) 
      }
    }
  }
}

.aside {
  margin-bottom: 30px;
  h3 { font-weight: normal; color: rgba(black, 0.5) }
  p { opacity: 0.3; }
}
            
          
!
            
              function searchReady() {
  var input = $('#search input');
  input.focus();

  input.keyup(function() {

    var inputVal = $(this).val(),
        strBank = 'directions to the nearest bank',
        strPizza = 'directions to make the best pizza';

    if (
      inputVal.indexOf("directions to the n") >= 0 &&
      strBank.indexOf(inputVal) >= 0
    ) {
      $('.ac').text(strBank).removeClass('ac-hidden');
      $('button').addClass('emoji emoji-bank');
     
    } else if (
      inputVal.indexOf("directions to make the b") >= 0 &&
      strPizza.indexOf(inputVal) >= 0
    ) {
      $('.ac').text(strPizza).removeClass('ac-hidden');
      $('button').addClass('emoji emoji-pizza');
      
    } else {
      $('.ac').addClass('ac-hidden').delay(300).text('');
      $('button').removeClass();
      
    }
  }); 
}

$(document).ready(searchReady);
            
          
!
999px
Loading ..................

Console