==CSS==
div.tothetopfixed {
position: fixed;
right: 15px;
bottom: 20px;
z-index: 1500;
}
div.tothetopfixed a {
display: block;
color: #ffffff;
padding: 10px;
margin: 0;
background-color: #FE2E2E;
border-radius: 5px;
font-size: 0.8em;
}
div.tothetopfixed a:hover {
background: #0044CC;
color: #ffffff;
}
===========================こここまで
<head></head>に
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'/>
<script type='text/javascript'>
$(function() {
var showFlug = false;
var topBtn = $('.tothetopfixed');
//最初はボタン位置をページ外にする
topBtn.css('bottom', '-100px');
var showFlug = false;
//スクロールが100に達したらボタン表示
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
if (showFlug == false) {
showFlug = true;
topBtn.stop().animate({'bottom' : '20px'}, 200);
}
} else {
if (showFlug) {
showFlug = false;
topBtn.stop().animate({'bottom' : '-100px'}, 200);
}
}
});
//スクロールしてトップに戻る
//500の数字を大きくするとスクロール速度が遅くなる
topBtn.click(function () {
$('body,html').animate({
scrollTop: 0
}, 500);
return false;
});
});
</script>
で</Body>の直前に
<div class='tothetopfixed'>
<a href='#header'>Go Top↑</a>
</div> <!--- end [tothetopfixed] -->