Skip to content

Instantly share code, notes, and snippets.

@justincron
Last active August 29, 2015 14:02
Show Gist options
  • Save justincron/a3c9ae99860cd09b48b6 to your computer and use it in GitHub Desktop.
Save justincron/a3c9ae99860cd09b48b6 to your computer and use it in GitHub Desktop.
Slidebox
<!doctype html>
<div id="last"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="slidebox">
<a class="close"></a>
<h2>Like us on facebook!</h2>
<p></p>
</div>
$(function() {
$(window).scroll(function(){
var distanceTop = $('#last').offset().top - $(window).height();
if ($(window).scrollTop() > distanceTop)
$('#slidebox').animate({'right':'0px'},300);
else
$('#slidebox').stop(true).animate({'right':'-430px'},100);
});
$('#slidebox .close').bind('click',function(){
$(this).parent().remove();
});
});
#slidebox{
width:400px;
height:100px;
padding:10px;
background-color:#fff;
border-top:3px solid #E28409;
position:fixed;
bottom:0px;
right:-430px;
-moz-box-shadow:-2px 0px 5px #aaa;
-webkit-box-shadow:-2px 0px 5px #aaa;
box-shadow:-2px 0px 5px #aaa;
z-index: 100;
text-align: center;
}
#slidebox p, a.more{
font-size:11px;
text-transform:uppercase;
font-family: Arial,Helvetica,sans-serif;
letter-spacing:1px;
color:#555;
}
a.more{
cursor:pointer;
color:#E28409;
}
a.more:hover{
text-decoration:underline;
}
#slidebox h2{
color:#E28409;
font-size:24px;
margin:10px 20px 10px 0px;
text-align: center;
}
close{
background:transparent url(/images/close.gif) no-repeat top left;
width:13px;
height:13px;
position:absolute;
cursor:pointer;
top:10px;
right:10px;
}
a.close:hover{
background-position:0px -13px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment