I currently have a div that appears when a user scrolls down a page. When clicked, it sends you back to the top of the page. Right now, it simply fades in and out, but I would like it to slide in from the right side of the page.
Below is my existing code:
Jquery:
<div class="toTop">
Back to the top
</div>
<script>
$(window).scroll(function() {
if ($(this).scrollTop()) {
$('.toTop').fadeIn();
} else {
$('.toTop').fadeOut();
}
});
</script>
CSS:
.toTop {
padding: 10px;
background: rgb(55,161,222);
color: #fff;
position: fixed;
bottom: 50%;
right: 0px;
display: none;
z-index:1000;
text-transform:uppercase;
font-weight:600;
}
You can view the implementation here: