A pet groomer's booking card looks like every other booking card: a heading, a price, a button. Nothing about it says the business actually likes animals. This card has two small ears hidden behind its top edge. As your pointer comes closer they peek out, then stand up fully and turn to follow you, with the odd flick while they wait. Tap the button and they give a happy wiggle. The card itself is plain text and a normal button.
Cat grooming
A calm bath and brush, no rush
One cat at a time in a quiet room. Coat brushed out, nails trimmed, ears cleaned. About 60 minutes.
$65 per visit
How it works
- Hide the ears behind the card. Two small SVG ears sit in a layer under the card. Pushed down by their own height, they are fully covered by the card, so nothing shows until the script lifts them.
- Measure how close the pointer is. On every pointer move the script works out the distance to the nearest edge of the card. Inside 160 pixels the ears start to rise; over the card, or with keyboard focus inside it, they stand up completely.
- Turn towards the pointer. Each ear gets an angle from its own base to the pointer, capped at 22 degrees either way. The script only sets two CSS custom properties per ear,
--ce-liftand--ce-turn, and a springy CSS transition does the moving. - Add a little life. While the ears are up, a timer flicks one of them every two to four seconds. Clicking the button plays a wiggle on both. The timer stops when the ears go down or the card scrolls off screen.
- Handle touch and calm settings. A tap has no hover, so the ears stay up for two and a half seconds after a touch and then sink. With reduced motion turned on, the ears simply fade in and out without sliding or turning.
The code
Three self contained blocks: the markup, the styles scoped to the ce- prefix, and a short script.
<div class="ce" data-lab="cat-ears">
<div class="ce-wrap">
<div class="ce-ears" aria-hidden="true">
<span class="ce-ear ce-ear-l"><svg viewBox="0 0 60 64" focusable="false"><path class="ce-out" d="M1 64C5 40 14 15 26 4Q30 0 34 4C46 15 55 40 59 64Z"/><path class="ce-in" d="M15 64C18 46 23 30 30 17C37 30 42 46 45 64Z"/></svg></span>
<span class="ce-ear ce-ear-r"><svg viewBox="0 0 60 64" focusable="false"><path class="ce-out" d="M1 64C5 40 14 15 26 4Q30 0 34 4C46 15 55 40 59 64Z"/><path class="ce-in" d="M15 64C18 46 23 30 30 17C37 30 42 46 45 64Z"/></svg></span>
</div>
<div class="ce-card">
<p class="ce-kicker">Cat grooming</p>
<h3 class="ce-title">A calm bath and brush, no rush</h3>
<p class="ce-text">One cat at a time in a quiet room. Coat brushed out, nails trimmed, ears cleaned. About 60 minutes.</p>
<div class="ce-row">
<p class="ce-price"><strong>$65</strong> per visit</p>
<button class="ce-book" type="button">Book a visit</button>
</div>
</div>
</div>
<p class="ce-status" aria-live="polite"></p>
</div>.ce {
display: grid;
justify-items: center;
gap: 10px;
padding: 64px 0 4px;
font-family: system-ui, sans-serif;
color: #101a14;
}
.ce-wrap { position: relative; width: 100%; max-width: 380px; }
/* The ears sit behind the card. Pushed down, the card hides them completely. */
.ce-ears { position: absolute; left: 0; right: 0; bottom: calc(100% - 12px); height: 66px; z-index: 0; }
.ce-ear {
--ce-lift: 100;
--ce-turn: 0;
--ce-show: 0;
position: absolute;
bottom: 0;
width: 64px;
height: 66px;
transform-origin: 50% 100%;
transform: translateY(calc(var(--ce-lift) * 1%)) rotate(calc(var(--ce-turn) * 1deg));
transition: transform .38s cubic-bezier(.3, 1.45, .5, 1);
}
.ce-ear-l { left: 13%; }
.ce-ear-r { right: 13%; }
.ce-ear svg { display: block; width: 100%; height: 100%; overflow: visible; transform-origin: 50% 100%; }
.ce-out { fill: #133621; }
.ce-in { fill: #f4d96c; opacity: .85; }
/* A quick flick of one ear, and a happy wiggle of both after a booking. */
.ce-flick { animation: ce-flick .42s ease-in-out; }
.ce-wiggle { animation: ce-wiggle .9s ease-in-out; }
@keyframes ce-flick { 30% { transform: rotate(-14deg) scaleY(.9); } 60% { transform: rotate(8deg); } }
@keyframes ce-wiggle { 20%, 60% { transform: rotate(-12deg); } 40%, 80% { transform: rotate(12deg); } }
.ce-card {
position: relative;
z-index: 1;
box-sizing: border-box;
padding: 24px 24px 22px;
border: 1px solid #c9cec4;
border-radius: 18px;
background: #fff;
box-shadow: 0 16px 34px -22px rgba(16, 26, 20, .45);
}
.ce .ce-card p { margin: 0; }
.ce .ce-kicker { font: 700 12px/1.2 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #46534a; }
.ce .ce-card .ce-title { margin: 8px 0 8px; padding: 0; border: 0; font: 700 21px/1.25 system-ui, sans-serif; letter-spacing: 0; color: #101a14; }
.ce .ce-card .ce-text { font-size: 15px; line-height: 1.5; color: #46534a; }
.ce-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.ce .ce-card .ce-price { font-size: 14px; color: #46534a; }
.ce .ce-price strong { font-size: 24px; color: #101a14; }
.ce .ce-book {
min-height: 44px;
padding: 0 20px;
border: 0;
border-radius: 999px;
background: #133621;
color: #f4d96c;
font: 600 15px/1 system-ui, sans-serif;
cursor: pointer;
}
.ce .ce-book:hover { background: #1d4a2f; }
.ce .ce-book:focus-visible { outline: 3px solid #f4d96c; outline-offset: 3px; box-shadow: 0 0 0 6px #133621; }
.ce .ce-status { min-height: 2.8em; margin: 0; font-size: 14px; font-weight: 600; color: #133621; text-align: center; }
/* Reduced motion: no sliding or swivelling, the ears simply fade in and out. */
@media (prefers-reduced-motion: reduce) {
.ce-ear { transform: none; opacity: var(--ce-show); transition: opacity .3s; }
.ce-flick, .ce-wiggle { animation: none; }
}(function () {
var root = document.querySelector('[data-lab="cat-ears"]');
if (!root) return;
var wrap = root.querySelector('.ce-wrap');
var card = root.querySelector('.ce-card');
var ears = root.querySelectorAll('.ce-ear');
var btn = root.querySelector('.ce-book');
var status = root.querySelector('.ce-status');
var NEAR = 160; // pixels: how far away the ears first notice the pointer
var MAX_TURN = 22; // degrees: how far an ear swivels towards the pointer
var REST = [-10, 10]; // degrees: resting outward tilt of the left and right ear
var calm = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
var px = -9999, py = -9999, focused = false, happy = false, alert = false, onScreen = true;
var raf = 0, flickTimer = 0, touchTimer = 0, happyTimer = 0;
// Restart a CSS animation on an element, then tidy the class away.
function play(el, cls) {
el.classList.remove(cls);
void el.getBoundingClientRect();
el.classList.add(cls);
}
root.addEventListener('animationend', function (e) {
e.target.classList.remove('ce-flick', 'ce-wiggle');
});
function update() {
raf = 0;
var r = card.getBoundingClientRect();
// Distance from the pointer to the nearest edge of the card (0 when over it).
var dx = Math.max(r.left - px, 0, px - r.right);
var dy = Math.max(r.top - py, 0, py - r.bottom);
var d = Math.sqrt(dx * dx + dy * dy);
var up = focused || happy || d === 0;
var lift = up ? 0 : d < NEAR ? 35 + 65 * d / NEAR : 100;
var w = wrap.getBoundingClientRect();
for (var i = 0; i < ears.length; i++) {
var ear = ears[i];
// Swivel each ear towards the pointer, measured from the base of that ear.
var ex = w.left + ear.offsetLeft + ear.offsetWidth / 2;
var turn = REST[i];
if (lift < 100 && px > -9000) {
var a = Math.atan2(px - ex, Math.max(r.top - py, 70)) * 180 / Math.PI;
turn += Math.max(-MAX_TURN, Math.min(MAX_TURN, a));
}
ear.style.setProperty('--ce-lift', calm ? 0 : lift.toFixed(1));
ear.style.setProperty('--ce-turn', calm ? 0 : turn.toFixed(1));
ear.style.setProperty('--ce-show', lift < 100 ? 1 : 0);
}
if (up !== alert) { alert = up; scheduleFlick(); }
}
function queue() { if (!raf) raf = requestAnimationFrame(update); }
// While the ears are fully up, one of them flicks now and then.
function scheduleFlick() {
clearTimeout(flickTimer);
if (!alert || !onScreen || calm) return;
flickTimer = setTimeout(function () {
play(ears[Math.random() < 0.5 ? 0 : 1].firstElementChild, 'ce-flick');
scheduleFlick();
}, 1600 + Math.random() * 2400);
}
document.addEventListener('pointermove', function (e) {
if (!onScreen) return;
clearTimeout(touchTimer);
px = e.clientX; py = e.clientY;
queue();
}, { passive: true });
document.documentElement.addEventListener('mouseleave', function () { px = py = -9999; queue(); });
window.addEventListener('scroll', function () { if (onScreen) queue(); }, { passive: true });
// A tap has no hover, so the ears stay up for a moment and then settle down.
card.addEventListener('pointerdown', function (e) {
px = e.clientX; py = e.clientY; queue();
});
document.addEventListener('pointerup', function (e) {
if (e.pointerType !== 'touch') return;
clearTimeout(touchTimer);
touchTimer = setTimeout(function () { px = py = -9999; queue(); }, 2500);
});
card.addEventListener('focusin', function () { focused = true; queue(); });
card.addEventListener('focusout', function (e) { focused = card.contains(e.relatedTarget); queue(); });
btn.addEventListener('click', function () {
status.textContent = 'Demo only, nothing was booked. On your site this would open the booking form.';
happy = true; queue();
for (var i = 0; i < ears.length; i++) if (!calm) play(ears[i].firstElementChild, 'ce-wiggle');
clearTimeout(happyTimer);
happyTimer = setTimeout(function () { happy = false; queue(); }, 2000);
});
// Stop the flick timer while the card is off screen.
if ('IntersectionObserver' in window) {
new IntersectionObserver(function (entries) {
onScreen = entries[0].isIntersecting;
if (onScreen) queue();
scheduleFlick();
}).observe(root);
}
update();
})();When to use it, and when not to
This is a personality touch, and it works best where personality is part of what you sell. A groomer, a cat cafe, a pet sitter, a vet clinic with a friendly tone, a shop selling handmade pet beds. Use it on one card, usually the main booking or featured offer, so it feels like a small surprise rather than a theme. Someone who notices the ears tends to remember the page.
It is a poor fit for a business where the tone is serious: a law office, a funeral home, a medical specialist. It also does nothing for a visitor who never moves a pointer near the card, so never put information inside the ears or rely on them to explain anything. The card has to make sense on its own, and here it does, because the ears are marked aria-hidden and the heading, price and button are ordinary HTML that screen readers and search engines read normally.
Movement near a button can distract some people, which is why the reduced motion version only fades. Keep the ears small and out of the way of the text, and do not add sound.
Make it yours
- How eager they are: raise
NEARto make the ears notice the pointer from further away, or lower it so they only appear right at the card. - How much they turn: change
MAX_TURNfor the swivel andRESTfor the resting tilt of the left and right ear. - Shape and colour: edit the two SVG paths for rounder or taller ears, and the
.ce-outand.ce-infill colours. Moving.ce-ear-land.ce-ear-rchanges how far apart they sit.
Frequently asked questions
Does it work on phones?
Yes. A tap on the card raises the ears and turns them towards your finger, and they settle back down a couple of seconds after you let go.
Will it slow my page down?
No. The script runs only when the pointer moves, does one small calculation per frame, and the movement itself is a CSS transition on two tiny SVG shapes.
Can I put the ears on something other than a card?
Yes. Any box with a solid background works: wrap it in .ce-wrap, keep the ears layer before it, and make sure the box is taller than the ears so it can hide them.