JSFiddle - React, Tailwind, and code Playground
by envira
HTML
<div class="search-include" style="margin-top: 31px; margin-bottom: 31px;">
<div class="search-button">
<a href="" class="open_s" style="display: block;">Open</a>
<a href="" class="close_s" style="display: none;">Close</a>
</div>
<div class="popup-search" style="top: 56.5px; display: none;">
<div class="form_wrap">
<form action="#" method="get" id="search_form">
<input type="text" id="srch_txt" value="Search..." onblur="if(this.value=='') this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue) this.value='';" class="ft" name="s" autocomplete="off">
<input name="action" type="hidden" value="the_search_text">
<input type="submit" value="" class="fs">
</form>
</div>
</div>
</div>
CSS
.search-include{
float:right;
width:30px;
margin:30px 0;
position:relative;
}
.search-include .search-button{
top:0;
}
.search-include .popup-search{
top:40px;
width:300px;
}
.search-button a{
font-size:18px;
color:#3c4852;
height:24px;
}
.search-button a i{
line-height:24px;
height:24px;
}
.search-button a.close_s{
display:none;
}
.popup-search{
width:300px;
padding:0;
background:#FFFFFF;
display:none;
position:absolute;
z-index:1;
top:53px;
right:0;
border:1px solid #ddd;
-moz-box-shadow: 0 0px 5px rgba(0,0,0,0.1);
-webkit-box-shadow: 0 0px 5px rgba(0,0,0,0.1);
box-shadow: 0 0px 5px rgba(0,0,0,0.1);
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
-ms-box-sizing: border-box; /* IE 10 + */
box-sizing: border-box; /* Opera/IE 8+ */
}
.popup-search .form_wrap{
padding:15px;
}
.popup-search form, .popup-search form input{
margin:0;
position:relative;
}
.popup-search input.ft{
width:100%;
padding:5px 15px;
border-right:none;
-webkit-border-radius:0 4px 4px 0;
-moz-border-radius:0 4px 4px 0;
border-radius:0 4px 4px 0;
}
.popup-search input.ft:focus{
box-shadow:none;
border-color:#ddd;
}
.popup-search input.fs{
background:url(framework/img/search.png) no-repeat center;
padding:7px 20px 6px 20px;
height:32px;
width:50px;
right:0;
top:0px;
position:absolute;
}
JavaScript
jQuery('.search-button a.close_s').css('display', 'none');
jQuery('.search-button a.open_s').click(function(){
jQuery('.popup-search').fadeIn(400, 'easeOutCubic');
jQuery(this).css('display', 'none');
jQuery('.search-button a.close_s').css('display', 'block');
return false;
});
jQuery('.search-button a.close_s').click(function(){
jQuery('.popup-search').fadeOut(400, 'easeOutCubic');
jQuery(this).css('display', 'none');
jQuery('.search-button a.open_s').css('display', 'block');
return false;
});