TipsBlocks Web Technique Library

PRACTICAL WEB TIP

← ライブラリへ戻る

カットマーク — ページトップボタン

角を切り落とした小さなタイルに明快な上矢印を収めたページトップボタン。

デザインプレビュー

まず形と大きさを確認。実際の動作は下のLive Demoで試せます。

造形とホバー
サイトでの実寸イメージ

Live Demo

枠内の「動作を試す」を押すか、枠の中をスクロールしてください。右下にボタンが現れ、クリックすると先頭へ戻ります。

Source Code

必要なコードをコピーして実装に利用できます。

HTML
<!-- TB-2059 / Cut Mark | paste before closing body -->
<button class="backtop tb-btt-button w2059" type="button" aria-label="Back to top"><span class="w59arrow">↑</span><span class="w59text">TOP</span></button>
CSS
/* TB-2059 / Cut Mark */
.backtop{box-sizing:border-box;position:fixed;z-index:50;cursor:pointer;opacity:0;visibility:hidden;pointer-events:none;transform:translateY(12px);text-align:center;transition:opacity .24s, transform .28s, visibility .24s}.backtop.is-visible{opacity:1;visibility:visible;pointer-events:auto;transform:translateY(0)}.backtop.w2055.is-visible{transform:translate(-50%,0)}.backtop:focus-visible{outline:3px solid #e7ab4c;outline-offset:4px}
.w2059{right:27px;bottom:27px;width:74px;height:72px;color:#fcfbf7;border:0;background:#375a49;clip-path:polygon(0 0,calc(100% - 18px) 0,100% 18px,100% 100%,0 100%);box-shadow:0 8px 25px #1f392935}.w59arrow{display:block;font:400 31px/1 Georgia,serif;margin-top:-1px;transition:transform .28s}.w59text{display:block;font:700 10px Arial,sans-serif;letter-spacing:.17em;margin-top:4px}.w2059:hover .w59arrow{transform:translateY(-5px)}.w2059:focus-visible{outline-offset:4px}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{transition-duration:.01ms!important;animation-duration:.01ms!important}}
/* POLISH PASS 2026-10-18: alignment, tactile size, emphasis & individual character */
.backtop{isolation:isolate;-webkit-tap-highlight-color:transparent;}
.backtop:focus-visible{outline:3px solid #f0af42;outline-offset:4px;}
@media(prefers-reduced-motion:reduce){.backtop,.backtop *{transition-duration:.01ms!important;animation-duration:.01ms!important}}

.w2059{right:clamp(21px,3vw,50px);bottom:clamp(32px,6vh,77px);width:76px;height:74px;background:#315c4b;clip-path:polygon(0 0,calc(100% - 21px) 0,100% 21px,100% 100%,0 100%);box-shadow:none;}
.w2059:before{content:'';position:absolute;top:0;right:0;width:21px;height:21px;background:#a8c5b4;clip-path:polygon(0 0,100% 100%,0 100%)}
.w2059:hover{background:#1f4337;transform:translateY(-5px)}
@media(max-width:650px){.w2059{right:19px;bottom:29px;width:70px;height:68px}}
JavaScript
(()=>{'use strict';const button=document.querySelector('.backtop');if(!button)return;const footerOnly=button.classList.contains('footer-backtop');const reduced=matchMedia('(prefers-reduced-motion: reduce)');let scheduled=false;function update(){scheduled=false;if(footerOnly)return;const shown=window.scrollY>160;button.classList.toggle('is-visible',shown);button.classList.toggle('is-hidden',!shown);button.tabIndex=shown?0:-1;button.setAttribute('aria-hidden',String(!shown));if(button.classList.contains('w2056')){const max=Math.max(1,document.documentElement.scrollHeight-innerHeight);button.style.setProperty('--progress',(Math.round(Math.min(100,scrollY/max*100)))+'%');}}function onScroll(){if(!scheduled){scheduled=true;requestAnimationFrame(update)}}button.addEventListener('click',()=>window.scrollTo({top:0,behavior:reduced.matches?'instant':'smooth'}));addEventListener('scroll',onScroll,{passive:true});addEventListener('resize',onScroll,{passive:true});update();})();

How to Use

HTMLのボタンをbody末尾付近へ設置し、CSSを読み込んでください。JavaScriptもdeferで読み込みます。実ページでスクロール後の表示・先頭復帰・スマートフォンでの位置を確認してください。

Use Case

商品紹介、店舗、クラフトショップ。

Technical Notes

ホバー非対応端末でも主要操作ができるようにし、キーボードフォーカス時の表示と動き軽減設定を確認してください。

Mobile:端末幅ごとにボタンの位置とタップ領域を確認してください。

Browser:モダンブラウザ向け。実際のページでのレイアウトを検証してください。

Reduced Motion:prefers-reduced-motion 設定によりアニメーションを抑制します。