TipsBlocks Web Technique Library

PRACTICAL WEB TIP

← Back to library

First Letter Flight — Back to First Letter

A paper-plane letter guides visitors back to the start of the story.

Design Preview

See the design above before trying the scroll interaction.

LOOK CLOSELY
IN PAGE CONTEXT

Live Demo

Press Try scrolling inside the frame, or scroll inside it. The button appears at the lower right and returns you to the top.

Source Code

Copy the HTML, CSS or JavaScript you need for your project.

HTML
<!-- TB-2084 / Back to Top: insert before closing body (inside footer for TB-2083) -->
<button class="tb-btt bt2084" data-backtop type="button" aria-label="最初の便り、ページ先頭へ戻る"><span class="plane-shadow"></span><span class="paper-plane"><i></i></span><span class="post-tag">はじめに戻る</span></button>
CSS
/* TB-2084 : paste only this CSS into the target page. */
.tb-btt{border:0;cursor:pointer;z-index:30;-webkit-tap-highlight-color:transparent;touch-action:manipulation;transition:transform .35s,opacity .3s,background .3s,color .3s,box-shadow .3s;pointer-events:none;opacity:0;visibility:hidden}.tb-btt.is-visible{pointer-events:auto;opacity:1;visibility:visible}.tb-btt:focus-visible{outline:3px solid #f9af4b;outline-offset:5px}.only-at-end{opacity:1;visibility:visible;pointer-events:auto}
.bt2084{position:fixed;right:17px;bottom:17px;width:142px;height:126px;background:none;color:#355864;display:flex;flex-direction:column;align-items:center;justify-content:flex-end}
.paper-plane{position:absolute;width:78px;height:70px;top:4px;left:34px;transform:rotate(-14deg);animation:paperFloat 4s ease-in-out infinite;filter:drop-shadow(7px 12px 6px #243c4233)}
.paper-plane:before{content:"";position:absolute;inset:0;background:#fffdf1;clip-path:polygon(0 52%,100% 0,58% 100%,42% 64%)}
.paper-plane i{position:absolute;inset:0;background:#acc4be;clip-path:polygon(0 52%,42% 64%,100% 0)}
.plane-shadow{position:absolute;width:70px;height:11px;background:#64858140;filter:blur(7px);border-radius:50%;bottom:47px;left:35px}
.post-tag{border-radius:999px;border:1px solid #9bbab7;background:#fffdf5;color:#34606b;font-size:12px;font-weight:700;padding:9px 14px;white-space:nowrap;box-shadow:0 8px 18px #4c6c6833}
@keyframes paperFloat{50%{transform:translateY(-10px) rotate(-9deg)}}
.bt2084:hover .paper-plane{transform:translateY(-25px) translateX(10px) rotate(-24deg)}
.bt2084:hover .post-tag{background:#316d73;color:#fff}
@media (max-width:700px){.bt2084{right:9px;bottom:9px;width:118px;transform:scale(.85);transform-origin:bottom right}}
@media(prefers-reduced-motion:reduce){.tb-btt,.tb-btt *{animation-duration:.01ms!important;transition-duration:.01ms!important}}
JavaScript
(()=>{'use strict';const control=document.querySelector('[data-backtop]');if(!control)return;const reduced=matchMedia('(prefers-reduced-motion: reduce)');const footer=control.classList.contains('only-at-end');let busy=false;function refresh(){busy=false;const max=Math.max(1,document.documentElement.scrollHeight-window.innerHeight);const p=Math.min(1,scrollY/max);document.documentElement.style.setProperty('--page-progress',p.toFixed(4));if(!footer){const show=scrollY>145;control.classList.toggle('is-visible',show);control.tabIndex=show?0:-1;control.setAttribute('aria-hidden',String(!show));}const number=document.querySelector('[data-progress-number]');if(number)number.textContent=Math.round(p*100)+'%';}function onscroll(){if(!busy){busy=true;requestAnimationFrame(refresh)}}addEventListener('scroll',onscroll,{passive:true});addEventListener('resize',onscroll,{passive:true});control.addEventListener('click',()=>window.scrollTo({top:0,behavior:reduced.matches?'instant':'smooth'}));refresh();})();

How to Use

Insert the HTML button near the end of body, load the CSS, and include JavaScript using defer. Test scrolling, returning to the top, and positioning on mobile.

Use Case

Stationery shops, letters and playful editorial sites.

Technical Notes

Keep controls usable on touch devices. Test keyboard focus and reduced-motion preferences.

Mobile:Check tap target, visibility and positioning on small screens.

Browser:Designed for current Chrome, Edge, Firefox and Safari.

Reduced Motion:CSS animations respect the reduced-motion preference.