🧠 Description
Create a smooth and modern text flipping animation that dynamically changes words with a subtle blur and vertical slide effect. This project uses HTML, CSS, and vanilla JavaScript to rotate multiple phrases seamlessly — perfect for hero sections, landing pages, and portfolios. The elegant animation enhances user engagement by displaying changing text like “Landing Pages,” “Component Blocks,” and more in a visually appealing manner.
💻 HTML Code
The HTML provides the structure of the animation. It contains:
A main div with the class layout-text-flip, which holds two text parts:
A static text — “Build Amazing”
A rotating text container that wraps around the changing text — “Landing Pages”
The script tag at the end links to the JavaScript file that controls the animation.
The link tag connects the CSS file for styling. In short, HTML sets up the skeleton for displaying the static and animated parts of the text.
CSS Code
The CSS defines the look and animation style of the text:
The body uses flexbox to center the content vertically and horizontally, with a dark background for contrast.
The .layout-text-flip class arranges the static and rotating text side by side with bold, white text styling.
The .rotating-text-container hides overflowing text and defines the area where the animation occurs.
The .rotating-text uses transition effects like translate, blur, and opacity to create a smooth sliding and fading motion when the text changes. Overall, CSS gives the animation a clean, modern, and glowing effect.
Javascipt Code
The JavaScript adds interactivity and animation control:
It stores multiple words (Landing Pages, Component Blocks, etc.) in an array.
It uses setInterval() to automatically switch the displayed word every 3 seconds.
When changing words, it applies transitions such as upward movement, blur, and fade-out — then updates the text and brings it back smoothly into view. Essentially, JavaScript controls the timing and logic behind the text transitions, making the effect dynamic and continuous.
