PR PR
宝島社
¥990 (2023/12/22 16:35時点 | Amazon調べ)

BLOGGERでブログトップまで移動できるアイコンを表示する方法

スポンサーリンク
新着情報
2023.04.09
2023.04.06
2023.04.03
2023.03.19
スポンサーリンク
スポンサーリンク

この記事は2013年4月8日の1年以上前に書かれたものです。現在は状況が異なる可能性がありますのでご注意ください。

記事内に広告が含まれています。

よくカスタマイズされて綺麗なブログHPなどで
見かける矢印アイコン。

その矢印アイコン等でクリックすると

スポンサーリンク

スポンサーリンク

ブログやHPの一番上まで移動する。

はじめての時は、ビックリしました!!ヽ(*'0'*)ツ ワァオォ!!

その方法です。

まずは、定番のテンプレート操作で、
テンプレート>HTML の編集で「ウィジェットのテンプレートを展開」にチェック
で、
以下を</head>の上に挿入します。

<script language='javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'/>
<script>
$(document).ready(function(){
// hide #back-top first
$("#back-top").hide();

// fade in #back-top
$(function () {
$(window).scroll(function () {
if ($(this).scrollTop() > 1000) {
$('#back-top').fadeIn();
} else {
$('#back-top').fadeOut();
}
});
// scroll body to 0px on click
$('#back-top a').click(function () {
$('body,html').animate({
scrollTop: 0
}, 400);
return false;
});
});
});
</script>
 

そして、
</body>の直上に以下を、
さらに挿入。

<p id="back-top">
<a href="#top"><span></span></a>
</p>

次に、
CSSの追記で、
以下を追加します。

/* backtotop */
#back-top {
position: fixed;
bottom: 5px;
right: 20px;
margin-right: 85%;
}
#back-top a {
width: 108px;
display: block;
text-align: center;
font: 11px/100% Arial, Helvetica, sans-serif;
text-transform: uppercase;
text-decoration: none;
color: #bbb;

/* transition */
-webkit-transition: 1s;
-moz-transition: 1s;
transition: 1s;
}
#back-top a:hover {
color: #000;
}

/* arrow icon (span tag) */
#back-top span {
width: 50px;
height: 50px;
display: block;
margin-bottom: 0px;
background: #eae5e3 url(※用意した画像のURL) no-repeat center center;

/* rounded corners */
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;

/* transition */
-webkit-transition: 1s;
-moz-transition: 1s;
transition: 1s;
}

#back-top a:hover span {
opacity:0.5;
}

これで、Bloggerブログの一番上まで一気に移動させるアイコンが、
表示されます。

*このブログにもありますm(__)m。

スポンサーリンク
タイトルとURLをコピーしました