Create a button that moves with the mouse using Tilt.js

Do you have a main button? Would you like to animate it with a dynamic, modern interaction? Let's learn how with the Tilt.JS library!
•
Updated on August 14, 2026
•
1 min read
Believemy logo

Do you have a main button? Do you want to animate it with a dynamic and modern interaction? Let’s learn together how to do it with the Tilt.JS library!

 

Step 1

The HTML code.

HTML
<a href="#" class="btn">
  Learn more
</a>

 

Step 2

Let's style the btn class.

CSS
.btn {
  font-family: arial;
  letter-spacing: 2px;
  font-size: 22px;
  text-transform: uppercase;
  background: #fc5185;
  color: #ffffff;
  border-radius: 10px;
  padding: 20px 24px;
  box-shadow: 0 0 60px -10px #CD106E;
  transition: all .3s;
  text-decoration: none;
}

 

Step 3

Now let's style the link when we hover over the element.

CSS
.btn:hover {
  box-shadow: 0 8px 65px -5px #CD106E;
}

 

Step 4

Add jQuery and Tilt.JS.

HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/tilt.js/1.2.1/tilt.jquery.min.js"></script>

Add first jQuery then Tilt to your website, because Tilt uses jQuery.

 

Step 5

Activate Tilt with the element.

JAVASCRIPT
$('.btn').tilt({ scale: 1.1, speed: 1000 });
Category: Developers

Share this article

Want to help us? Share this article on your networks or even better: on your site, in an article or in your newsletter.

Believemy logo
Comments (0)

You need to be logged in to comment on this article: log in or sign up.

Read next

Create an animated "rainbow" button with CSS

In this article, we'll show you how to create a rainbow button that comes to life when the mouse hovers over it. A modern and sensational effect guaranteed!

December 9, 2024

Create an animated 3D button using CSS

In this article, we'll find out how to create a three-dimensional button that will add a touch of softness and perspective to your projects!

December 9, 2024

Animate emojis like on Discord with JavaScript

Would you like to create a button whose emoji changes every time you move your mouse over it? Like on Discord? Then this article is for you!

December 9, 2024

Create a very modern hover on a link

Here's an easy way to create a very modern hover on a link! There are lots of possible effects for buttons and links: the better they look, the more likely your users will be to click on them.

December 9, 2024

Creating circled buttons on hover with HTML and CSS

For a menu or to encourage your readers to share your website, share buttons are essential elements to add to your website. Let's find out how to make them more modern with a "neon" effect that will surround the icon selected by your user.

December 9, 2024

Creating a sinking button with CSS

The buttons on a site are the main triggers for action: styling them and making them dynamic is very important in your development process! That's the aim of this article.

December 9, 2024

Create a glitch effect on mouse-over with CSS

Add a modern glitch effect to your presentations or your logo, whether it's hovering or permanent! Let's find out how.

December 9, 2024

Create an "architectural" design button using CSS

Creating a button where the borders split in two on hover may seem complicated, but nothing could be easier! Let's find out how in this article.

December 9, 2024

Become the solopreneur you dream of being.

First project, career change, business launch: access our courses, practice on real-world cases, and move forward with clear guidance.