Home / Free downloads / 3D Tilt Card

3D Tilt Card: a hover effect with depth

Cards that lean toward the pointer, with text that floats above the surface and a light that follows the mouse. Plain JavaScript, one attribute, no library.

How to use it

1. Add the script

<script src="tilt.js"></script>

2. Add one attribute to your card

<div class="card" data-tilt>
  Your content
</div>

3. Add glare and floating layers

The glare is a soft light that follows the mouse. Children with data-tilt-depth lift off the card, which gives the real 3D feeling.

<div class="card" data-tilt data-tilt-glare data-tilt-max="14">
  <h3 data-tilt-depth="60">Floats high</h3>
  <p data-tilt-depth="30">Floats a little</p>
</div>

All options

AttributeDefaultWhat it does
data-tiltSwitches the effect on for this element.
data-tilt-max="14"12The strongest angle in degrees. Use 5 to 8 for a calm look.
data-tilt-scale="1.05"1.03How much the card grows while hovered. Use 1 for no zoom.
data-tilt-glareoffAdds the moving light reflection.
data-tilt-depth="40"Goes on a child. Lifts it this many pixels above the card.

Tips for a good result

  • Give the card a background and rounded corners. The glare takes the same corner radius automatically.
  • Keep the angle small on large cards. A wide card at 20 degrees looks wild. 6 to 10 is enough.
  • Do not put it on everything. It works best on three or four cards per page.

What happens on phones

Touch screens have no hover, so the cards stay flat there. Scrolling is never blocked. Visitors who turned off animations in their system also get flat cards.

Common questions

The floating text is cut off. Why?

The card has overflow: hidden. Remove it from the card, or lower the depth value.

Can I use it on images?

Yes. Wrap the image in a div with data-tilt. The image tilts with it.

What is in the download

  • tilt.js the script, about 2 KB
  • index.html and demo.css the demo page you see above
  • README.txt and LICENSE.txt the short guide and the MIT licence

Licence

MIT licence. Use it in personal and commercial projects, change it as you like. A link back is welcome and not required.