PRACTICAL WEB TIP
Tanuki Guide — Animated Mascot
A friendly tanuki guide gives a small motion cue and reacts when hovered.
Design Preview
See the design above before trying the scroll interaction.
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.
<!-- TB-2062 / Tanuki Guide / ご案内係 | paste before the closing body tag (inside the footer for TB-2069) -->
<button aria-label="ページの先頭へ戻る" class="btt tanuki tb-btt-2062" type="button"><span class="speech">また最初から</span><img alt="" src="https://tipsblocks.com/wp-content/uploads/tipsblocks-btt-2061-2072/assets/tanuki.webp"/></button>
/* 2062 / production button rules only */
.tb-btt-2062{box-sizing:border-box;font:inherit;cursor:pointer}.tb-btt-2062 :is(span,i,em,b,small,img){box-sizing:border-box}
.btt.tb-btt-2062{position:fixed;z-index:90;border:0;cursor:pointer;-webkit-tap-highlight-color:transparent;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .28s ease,visibility .28s ease,transform .35s ease}.btt.tb-btt-2062:focus-visible{outline:3px solid #f0af43;outline-offset:5px}.tb-btt-2062 .tanuki{right:10px;bottom:12px;width:118px;background:transparent;transform:translateY(8px)}.tb-btt-2062 .tanuki img{display:block;width:100%;filter:drop-shadow(0 12px 9px #44351b22);animation:tb-btt-2062-steps 4.1s ease-in-out infinite;transform-origin:50% 100%;transition:transform .4s}.tb-btt-2062 .tanuki .speech{position:absolute;right:85%;top:15px;white-space:nowrap;background:#fff9e4;border:2px solid #735340;color:#583b25;border-radius:18px 18px 3px 18px;padding:8px 11px;font:700 11px/1.3 "Yu Gothic",sans-serif;opacity:0;transform:translate(6px,6px);transition:.24s}.tb-btt-2062 .tanuki:hover .speech,.tb-btt-2062 .tanuki:focus-visible .speech{opacity:1;transform:none}.tb-btt-2062 .tanuki:hover img{transform:translateY(-9px) rotate(-8deg)}@media (max-width:600px){.tb-btt-2062 .tanuki{width:92px;right:4px}.tb-btt-2062 .tanuki .speech{right:74%;font-size:10px}}
@keyframes tb-btt-2062-steps{0%,85%,100%{rotate:0deg}89%{rotate:-3deg}93%{rotate:2deg}}
@media(prefers-reduced-motion:reduce){.tb-btt-2062,.tb-btt-2062 *{animation-duration:.01ms!important;transition-duration:.01ms!important}}
(()=>{'use strict';const target=document.querySelector('.btt, .footer-return');if(!target)return;const isFooter=target.classList.contains('footer-return');const reduced=matchMedia('(prefers-reduced-motion: reduce)');let active=false;const update=()=>{const y=window.scrollY;const p=Math.max(0,Math.min(1,y/Math.max(1,document.documentElement.scrollHeight-innerHeight)));if(!isFooter){const visible=y>160;target.classList.toggle('is-visible',visible);target.setAttribute('aria-hidden',String(!visible));target.tabIndex=visible?0:-1;}target.style.setProperty('--pct',p.toFixed(3));const txt=target.querySelector('[data-progress]');if(txt)txt.textContent=String(Math.round(100*p)).padStart(2,'0')+'%';};const scroll=()=>{if(active)return;active=true;requestAnimationFrame(()=>{active=false;update()})};target.addEventListener('click',()=>window.scrollTo({top:0,behavior:reduced.matches?'instant':'smooth'}));addEventListener('scroll',scroll,{passive:true});addEventListener('resize',scroll,{passive:true});update();})();
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
Local tourism, town guides and playful destination 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.