blog
blog Banner

Let’s Craft a Bouncy Button: HTML, CSS, and SVG Style for Recruitment Rebels!

Posted On Monday, December 18, 2023

Author: David Armitage (Technical Director)

Guess what? A rubber button I tossed onto CodePen just hit over 11,000 views! Now, let’s unravel the magic behind this bouncy beauty. Buckle up for a journey into accessibility improvements and compatibility tweaks – because who said coding can't be a rollercoaster ride?

The Grand Finale

Ready for the thrill? Hover or tap the button in your browser to witness the rubbery dance:

Step 1: SVG Shenanigans

Our stage is set with three SVG paths – one for the default, one for the hover, and one for the button's pressed state. They're like the choreography steps of our button ballet. Pro tip: I find it easier to handcraft these paths, like an artist with a paintbrush, rather than wrestling with a design tool.

Step 2: The HTML Showdown

Our star performer – an actual button element! Applause for native functionality! Plus, an SVG element housing the default shape path. Mark it as 'aria-hidden="true"’ – it’s decorative, not the lead singer. Add ‘preserveAspectRatio="none"’ for a free-spirited stretch to match our button's size. And don't forget the text container for the animated button text.

Step 3: Styling the Jam

Time to outfit our button! The stage is set with relative positioning – think of it as our backstage pass for arranging the SVG shape. Set the background to transparent, letting our shape take the spotlight.

Step 4: The Transition Tango

Let’s dance with custom properties for synchronized transitions. We're adding a touch of spring with an ease-out-back bezier function. And why not scale elements by 5% for that extra bounce? Duration is set to 0s for the motion-sensitive audience.

Now, let’s add some transitions. A brightness filter on the button will shade or highlight based on viewer proximity – cue the spotlight!

Pushing Boundaries

The encore options are endless:

  • Splash on gradients, strokes, or other visual fireworks.
  • Mix it up with scroll-driven animations for a dynamic entrance and exit.
  • Dive into JavaScript wonders like GreenSock’s MorphSVG plugin for morphing magic.
  • Elevate it to a web component, spreading the bouncy joy across your digital stage.

Remember, use this power responsibly – too much bounciness can steal the show. But when applied with purpose, it turns the mundane into a memorable experience!


Author: David Armitage (Technical Director)

10 Years+ experience building software, job boards, and websites for the recruitment industry.

Please feel free to contact me for a free consultation, a technical review of your website, or information regarding the services we offer.

You can reach me at david@recsitedesign.com or find me on LinkedIn.