🔥 Description
A visually engaging UI component that displays three tourist attraction cards with 3D perspective, tilt animations, hover effects, and color-themed gradients. Each card lifts up from a 3D transformed state to a flat, elevated display when hovered. Designed using HTML and CSS only.
🧠 How the Component Works
📄 HTML Code
🌐 1️⃣ HTML Explanation
The HTML creates the structure for three tourist attraction cards and the title.
The document begins with the DOCTYPE declaration and sets the language to English. Inside the head section, metadata and a link to the external CSS file are defined. The body contains a main title inside a div where each part of the text is styled with a different color using inline span styling.
Below the title, there are three separate card containers named card1, card2, and card3. Each card contains an image tag for displaying the attraction, a heading for the site name, and a paragraph describing the location. These divs act as the base blocks that CSS later transforms into 3D hover cards.
At the end of the document, there is a footer div to reserve space for future footer text.
🎨 CSS Code
🎨 2️⃣ CSS Explanation
The CSS begins by importing two Google Fonts, Exo and Abel, used for the title and card text. The body has a light gray background and is given 3D rendering properties using perspective and transform-style to enable the dramatic hover motion.
The title section centers the heading and applies large, bold typography. Each card has absolute positioning to place them horizontally across the screen. The cards have a fixed width and height and use linear gradients for colorful backgrounds. A shadow is added to create depth.
To create the 3D effect, each card is rotated on the X-axis by 75 degrees and moved forward and upward using translateY and translateZ. This makes them appear as if they are lying flat in the distance.
On hover, the transform is reset to a 0-degree rotation, making the card stand upright. The transition smooths the animation, and the shadow is softened to give a glowing appearance. Each card uses slightly different styling and sizing for its images. The second card has an infinite animation assigned, although no keyframes are defined in the provided code, meaning the animation has no visible effect until keyframes are added.
The global h3 heading and p text styles are applied to all cards. Text alignment, color, and spacing are adjusted to ensure readability against the gradient backgrounds.
The footer is positioned lower on the page with centered alignment.
