Skip to content

3D tilt card on hover in WordPress

Each card pivots in perspective towards the hovered area, with a glare and a cast shadow that follow the mouse.

Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in WordPress

effet-carte-inclinaison-3d.php
<?php
/**
 * Plugin Name: Forge, Carte qui s’incline en 3D au survol
 * Description: Chaque carte pivote en perspective vers la zone survolée, avec un reflet et une ombre portée qui suivent la souris. Ajoute la composition « Carte qui s’incline en 3D au survol » à l'éditeur de blocs.
 * Version: 1.0.0
 * Requires at least: 6.6
 * Requires PHP: 8.1
 * Author: Forge
 * License: GPL-2.0-or-later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: forge-effet-carte-inclinaison-3d
 *
pattern.html
<!-- wp:html -->
<section class="efci" aria-labelledby="efci-titre" data-efci>
        <header class="efci__head">
          <p class="efci__eyebrow">Atelier Grès &amp; Cendre · Céramiste à Dieulefit</p>
          <h2 class="efci__title" id="efci-titre">Apprendre le tour, une motte à la fois</h2>
          <p class="efci__text">Des cours en petit groupe dans l’atelier, avec la terre, les outils et la cuisson compris dans le prix.</p>
        </header>
        <div class="efci__grid">
          <div class="efci__item" data-efci-item>
            <span class="efci__shadow" aria-hidden="true" data-efci-shadow></span>
            <article class="efci__card" data-efci-card>
              <span class="efci__glare" aria-hidden="true" data-efci-glare></span>
script.js
(() => {
  if (!document.querySelector(".efci")) return;
  document.querySelectorAll("[data-efci]").forEach((zone) => {
    const reduce = window.matchMedia("(prefers-reduced-motion: reduce)");
    const clamp = (value) => Math.max(-1, Math.min(1, value));

    zone.querySelectorAll("[data-efci-item]").forEach((item) => {
      let point = null;
      let frame = 0;

      const paint = () => {
        frame = 0;
style.css
:root {
  --efci-bg: #f1e8dc;
  --efci-card: #fffaf3;
  --efci-line: #e2d3c1;
  --efci-text: #2a1d14;
  --efci-body: #5b4636;
  --efci-accent: #9a3412;
  --efci-shine: rgb(255 255 255 / 0.7);
  --efci-cast: rgb(91 52 26 / 0.4);
  --efci-tilt: 10deg;
  --efci-depth: 50rem;
  --efci-radius: 1.25rem;

Free component: copy it freely, including for commercial projects.

Visual effects components in WordPress
  • Cards that fade in as they enter the screen, one after another in each row, without a line of JavaScript and with a static fallback.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A translucent card with a saturated blur whose sharper edge refracts the colourful shapes drifting behind it, with an opaque fallback when transparency is reduced.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A help block shaped like a conversation: bubbles, three animated typing dots and clickable quick replies that show your answers to frequent questions, frozen under prefers-reduced-motion.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A paragraph whose words turn from grey to full ink, one by one, as the page scrolls, in pure CSS with a plain-text fallback.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Four offset, translucent sine waves gently roll along the bottom of a section, each at its own pace.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component