Text Flipping Animation Effect Using HTML and CSS
The Text Flipping Animation Effect is a visually engaging feature that makes text appear to flip in 3D, adding a dynamic element to web pages. This effect enhances user experience by creating an interactive and stylish look for text elements.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Text With Flipping Animation</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #5a0017;
}
.flipping-animation {
display: flex;
justify-content: center;
}
.flipping-animation > span {
font-size: 5rem;
font-weight: 600;
color: #01969b;
text-shadow: 2px 2px 2px #000;
animation: flipping 4s infinite;
}
.flipping-animation > span:nth-child(1) {
animation-delay: 0.2s;
}
.flipping-animation > span:nth-child(2) {
animation-delay: 0.4s;
}
.flipping-animation > span:nth-child(3) {
animation-delay: 0.6s;
}
.flipping-animation > span:nth-child(4) {
animation-delay: 0.8s;
}
.flipping-animation > span:nth-child(5) {
animation-delay: 1s;
}
.flipping-animation > span:nth-child(6) {
animation-delay: 1.2s;
}
.flipping-animation > span:nth-child(7) {
animation-delay: 1.4s;
}
.flipping-animation > span:nth-child(8) {
animation-delay: 1.6s;
}
.flipping-animation > span:nth-child(9) {
animation-delay: 1.8s;
}
@keyframes flipping {
0%,
80% {
transform: rotateY(360deg);
}
}
</style>
</head>
<body>
<div class="flipping-animation">
<span>C</span>
<span>O</span>
<span>D</span>
<span>E</span>
<span>W</span>
<span>h</span>
<span>e</span>
<span>e</span>
<span>l</span>
</div>
</body>
</html>
HTML Structure: The animation starts with a simple HTML setup, featuring a container that holds the text element to be animated.
Basic Styling: Basic CSS is applied to position the text centrally on the page, set the background color, and style the text with properties such as padding, font size, and border-radius.
Flip Animation: A keyframes animation is defined to create a flipping effect. Using
rotateX
, the text element is rotated 360 degrees along the X-axis, making it appear to flip.Smooth Transitions: Additional CSS properties like
transform-origin
andbackface-visibility
ensure that the flip is smooth and visually appealing. Thetransform-origin
property centers the flip, whilebackface-visibility: hidden
hides the back side of the text during the flip.Interactive Hover Effect: The animation is triggered by a hover effect, adding an interactive element to the text. When the user hovers over the container, the text flips, creating a dynamic and engaging user experience.
This effect is highly customizable, allowing for changes in colors, sizes, and animation timings to fit various design needs. It is a simple yet effective way to enhance the visual appeal of text on a webpage.