Build a 3D Tilt Card Gallery with Pointer Glare and Touch Fallback in One HTML File

Get one HTML page with a grid of cards that tilt in 3D toward the pointer, show a moving glare, and fall back to gentle auto-tilt on touch devices. Includes keyboard focus and reduced-motion handling.

You getComplete HTML in one code block, checklist table and risks and next actions

The prompt

Prompt
Role: You are a front-end engineer experienced in CSS 3D transforms and interaction design.Context: I am designing a gallery of online course (example value for {content_type}) cards. The job to be done is to decide whether a 3D tilt interaction is worth adding, so the page must let me tune it and judge readability.

Inputs:
- Content type: online course (example value for {content_type})
- Number of cards: 6 (example value for {card_count})
- Maximum tilt in degrees: 10 (example value for {max_tilt_degrees})
- Accent color: #7C5CFF (example value for {accent_color})
Put any assumptions in a separate Assumptions section.

Task: Build ONE self-contained HTML file with inline CSS and vanilla JS. No libraries and no external images; use CSS gradients or inline SVG for card art.

Workflow:
1. Render 6 (example value for {card_count}) cards in a responsive grid, each with a title, a one-line description and a gradient or SVG artwork area. Write realistic copy, not filler.
2. On pointermove, compute rotateX and rotateY from the pointer position relative to the card center, capped at 10 (example value for {max_tilt_degrees}). Apply with perspective and smooth easing back to flat on leave.
3. Add a radial-gradient glare layer that follows the pointer via CSS variables.
4. Use translateZ on inner layers (title, art) for a parallax depth effect.
5. On touch devices without hover, use a slow automatic idle tilt that stops when the card is tapped.
6. Add a small control bar: tilt strength slider, glare on/off, perspective distance slider.

Constraints:
- Update styles inside requestAnimationFrame, and only animate transform and opacity.
- Cards must be focusable; on focus show a subtle fixed tilt and a visible outline.
- Respect prefers-reduced-motion by disabling tilt and glare.
- Text must remain legible during tilt; keep contrast at 4.5:1 or better.

Output format:
1. Assumptions
2. Complete HTML in one code block
3. Checklist table: item, pass/fail expectation, how to test
4. Risks and next actions (for example text blur on some GPUs, nested links)

Acceptance criteria:
- Tilt never exceeds 10 (example value for {max_tilt_degrees}) degrees.
- Cards return to flat smoothly with no jump.
- Layout does not shift during interaction.
- Works with mouse, touch and keyboard.

Quality checks: Verify the math handles card edges, that glare does not cover text, that all {variable} values were applied, and that no external requests exist. Tool note: in Claude, use a single HTML artifact; in ChatGPT, one code block with no explanation inside it; in Cursor, create index.html and avoid frameworks.

Dashed parts are example values, so the prompt runs as copied. Change them in Fill in the blanks.

Use it to prototype product, portfolio or course cards. If text looks soft during tilt, ask for will-change and backface-visibility tweaks. Keep tilt under 12 degrees for content-heavy cards.

Make it repeatable

Keep using this prompt without pasting it in every time.

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Keep exploring

More in Animations & Effects