A Pen by Intuitive Company on CodePen.
Created
February 13, 2014 14:28
-
-
Save pavsmk/8975947 to your computer and use it in GitHub Desktop.
A Pen by Intuitive Company.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="wrapper"> | |
<div class="icon-search-container" data-ic-class="search-trigger"> | |
<span class="fa fa-search"></span> | |
<input type="text" class="search-input" data-ic-class="search-input" placeholder="Search"/> | |
<span class="fa fa-times-circle" data-ic-class="search-clear"></span> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
var $searchTrigger = $('[data-ic-class="search-trigger"]'), | |
$searchInput = $('[data-ic-class="search-input"]'), | |
$searchClear = $('[data-ic-class="search-clear"]'); | |
$searchTrigger.click(function(){ | |
var $this = $('[data-ic-class="search-trigger"]'); | |
$this.addClass('active'); | |
$searchInput.focus(); | |
}); | |
$searchInput.blur(function(){ | |
if($searchInput.val().length > 0){ | |
return false; | |
} else { | |
$searchTrigger.removeClass('active'); | |
} | |
}); | |
$searchClear.click(function(){ | |
$searchInput.val(''); | |
}); | |
$searchInput.focus(function(){ | |
$searchTrigger.addClass('active'); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { box-sizing: border-box; } | |
*, body { | |
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; | |
font-weight: 300; | |
} | |
.wrapper { | |
text-align: center; | |
margin: 100px auto; | |
} | |
.icon-search-container { | |
display: inline-block; | |
border: 2px solid #d9d9d9; | |
border-radius: 50px; | |
height: 50px; | |
width: 50px; | |
position: relative; | |
transition: width 0.4s ease-out; | |
backface-visibility: hidden; | |
&.active { | |
width: 285px; | |
.fa-times-circle { | |
opacity: 1; | |
} | |
.search-input { | |
width: 200px; | |
} | |
} | |
.fa-search { | |
color: #2980b9; | |
font-size: 30px; | |
position: absolute; | |
top: 7px; | |
left: 8px; | |
cursor: pointer; | |
} | |
.fa-times-circle { | |
opacity: 0; | |
color: #d9d9d9; | |
font-size: 20px; | |
position: absolute; | |
top: 12px; | |
right: 8px; | |
transition: opacity 0.4s ease-out; | |
cursor: pointer; | |
} | |
.search-input { | |
position: absolute; | |
cursor: default; | |
left: 45px; | |
top: 6px; | |
width: 0; | |
padding: 5px; | |
border: none; | |
outline: none; | |
font-size: 18px; | |
line-height: 20px; | |
background-color: rgba(255, 255, 255, 0); | |
transition: width 0.4s ease-out; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment