Skip to content

Instantly share code, notes, and snippets.

@shehabkhan013
Created July 31, 2019 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shehabkhan013/bf8aaf19207e1036c01248922da74919 to your computer and use it in GitHub Desktop.
Save shehabkhan013/bf8aaf19207e1036c01248922da74919 to your computer and use it in GitHub Desktop.
Mobile Search Option
.mobile-search {
position: absolute;
right: 65px;
top: 50%;
z-index: 9999;
background: #4F2271;
border-radius: 22.5px;
display: none;
transform: translateY(-50%);
}
.mobile-search {
display: block;
right: 85px;
}
.mobile-search input[type="search"] {
height: 40px;
width: 40px;
}
.mobile-search:after {
position: absolute;
right: 12px;
top: 50%;
content: "";
background: transparent;
text-align: center;
line-height: 40px;
color: #fff;
background-image: url(assets/img/search-glass.png);
background-size: cover;
padding: 8px;
cursor: pointer;
transform: translateY(-50%);
z-index: 1;
}
.mobile-search input[type="search"]:focus {
width: 235px;
}
<div class="mobile-search">
<div class="input-group">
<input type="search" class="form-control" placeholder="Find a recipe, brand or promotion...">
</div>
</div>
(function {
var searchBtn = '.header-search';
var searchWrap = '.search-wrap';
$(searchBtn).click(function () {
$(searchWrap).css("display", "block");
});
$(document).click(function (e) {
if (!$(e.target).parents().andSelf().is(searchBtn)) {
$(searchWrap).css("display", "none");
}
});
$(searchWrap).click(function (e) {
e.stopPropagation();
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment