Skip to content

Instantly share code, notes, and snippets.

Created April 22, 2016 01:08
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 anonymous/aa11c5bd2f6df55cc2a228a011dda00e to your computer and use it in GitHub Desktop.
Save anonymous/aa11c5bd2f6df55cc2a228a011dda00e to your computer and use it in GitHub Desktop.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
$(function () {
/** ページトップ処理 **/
// スクロールした場合
$(window).scroll(function() {
// スクロール位置が1000を超えた場合
if ($(this).scrollTop() > 1000) {
$('#pagetop').fadeIn();
} else {
// ページトップへをフェードアウト
$('#pagetop').fadeOut();
}
});
// ページトップクリック
$('#pagetop').click(function() {
// ページトップへスクロール
$('html, body').animate({
scrollTop: 0
}, 300);
return false;
});
})(jQuery);
</script>
<a id="pagetop" href="#top" class="page_top" style="display: none;"><img src="画像のURL" alt="ページTOPへ"></a>
/* ページトップへ戻るボタン */
#pagetop {
position:fixed;
bottom:10px;
right:300px;
padding:0;
}
/* ページトップへ戻るボタン:ホバー時に画像が白みがかったようにする*/
#pagetop:hover {
cursor:pointer;
filter: alpha(opacity=60); /* ie lt 8 */
-ms-filter: "alpha(opacity=60)"; /* ie 8 */
-moz-opacity:0.6; /* FF lt 1.5, Netscape */
-khtml-opacity: 0.6; /* Safari 1.x */
opacity:0.6;
zoom:1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment