Skip to content

Instantly share code, notes, and snippets.

@ScarletPonytail
Last active November 27, 2017 11:41
Show Gist options
  • Save ScarletPonytail/c6985afac4a19e4a13e355287d6ad3cd to your computer and use it in GitHub Desktop.
Save ScarletPonytail/c6985afac4a19e4a13e355287d6ad3cd to your computer and use it in GitHub Desktop.
CSS / JS / HTML - Off Canvas Top
<div class="the-search">
<!-- Something here -->
</div>
// Off canvas search (with two separate buttons)
$(function() {
var expanded = false;
$('.appear').click(function() {
if (!expanded) {
$('.the-search').animate({ 'height': '150px' }, { duration: 400 });
expanded = true;
}
});
$('.disappear').click(function() {
if (expanded) {
$('.the-search').animate({ 'height': '0px' }, { duration: 400 });
expanded = false;
}
});
});
// Off canvas search (with one button)
$(function() {
var expanded = false;
$('.appear').click(function() {
if (!expanded) {
$('.the-search').animate({ 'height': '150px' }, { duration: 400 });
expanded = true;
} else {
$('.the-search').animate({ 'height': '0px' }, { duration: 400 });
expanded = false;
}
});
});
/* Off Canvas Function */
.the-search {
width: 100%;
height: 0px;
background-color: #009742;
position: fixed;
overflow: hidden;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment