Skip to content

Instantly share code, notes, and snippets.

@ingozoell
Last active March 11, 2017 17:33
Show Gist options
  • Save ingozoell/47cc4a0faebf04dcefb0abcfe77e7cda to your computer and use it in GitHub Desktop.
Save ingozoell/47cc4a0faebf04dcefb0abcfe77e7cda to your computer and use it in GitHub Desktop.
To Top Button
.back-to-top {
position: fixed;
bottom: 18px;
right: 50px;
color: #282828;
-webkit-transition: all .3s ease;
transition: all .3s ease;
}
.back-to-top:hover {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
color: #282828;
}
/* To-Top BTN */
// Der Button wird mit JavaScript erzeugt und vor dem Ende des body eingebunden.
var back_to_top_button = ['<a href="#top" class="back-to-top"><i class="fa fa-2x fa-angle-double-up"></i></a>'].join("");
$("body").append(back_to_top_button)
// Der Button wird ausgeblendet
$(".back-to-top").hide();
// Funktion für das Scroll-Verhalten
$(function () {
$(window).scroll(function () {
if ($(this).scrollTop() > 300) { // Wenn 300 Pixel gescrolled wurde
$('.back-to-top').fadeIn();
} else {
$('.back-to-top').fadeOut();
}
});
$('.back-to-top').click(function () { // Klick auf den Button
$('body,html').animate({
scrollTop: 0
}, 800);
return false;
});
});
// To-Top BTN
$(function() {
var back_to_top_button = ['<a href="#top" class="back-to-top"><i class="fa fa-3x fa-arrow-circle-o-up"></i></a>'].join("");
$(".no-touch body").append(back_to_top_button)
$(".back-to-top").hide();
var topOfOthDiv = $("#angebot").offset().top;
$(window).scroll(function() {
if($(window).scrollTop() > topOfOthDiv) {
$('.back-to-top').fadeIn(800);
} else {
$('.back-to-top').fadeOut(400);
}
});
// Der Button wird ausgeblendet
$(".back-to-top").hide();
$('.back-to-top').click(function () { // Klick auf den Button
$('body,html').animate({
scrollTop: 0
}, 800, "easeInExpo");
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment