Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • jQuery
  • AngularJS
  • ReactJS
  • Next.js
  • React Native
  • NodeJS
  • Express.js
  • MongoDB
  • MERN Stack
  • PHP
  • WordPress
  • Bootstrap
  • Tailwind
  • CSS Frameworks
  • JS Frameworks
  • Web Development
Open In App
Next Article:
Rubber Band Text animation using HTML and CSS
Next article icon

Animation ideas for web pages using HTML & CSS

Last Updated : 01 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Straight forward and simple web pages are good but not the best. The animation is the thing that brings life to a static page and makes it more eye-catchy.

Here are a few ideas of animation for your web pages using the frontend languages like HTML & CSS. 

1. Rotating a Card: The first one is rotating a card. The card has two things front side and the backside when we hover our mouse to the card it will rotate 180 degrees and it will show the backside only.

Explanation: Here the first whole body is styled the image. The button is styled according to your need and creativity. The main thing here is the rotation at first the backside is hidden or rotated 180 degrees and when we hover to the card the front side is rotating -180 degrees and the backside is coming in the front.

Below is the example that illustrates the Rotating card animation.

Example:

HTML
<!DOCTYPE html> <html lang="en">  <head>     <style>         body {             color: hsl(209, 61%, 16%);             background: #fff;             ;         }          img {             width: 100%;             display: block;         }          .btn {             background: white;             color: rgb(64, 119, 64);             padding: 0.375rem 0.75rem;             letter-spacing: 3px;             display: inline-block;             border: 2px solid transparent;             border-radius: .5rem;             cursor: pointer;         }          .blog {             background: hsl(210, 36%, 96%);         }          .card {             height: 500px;             position: relative;             width: 500px;             margin-left: 30rem;         }          .card-side {             -webkit-transition: all 2s linear;             transition: all 2s linear;             -webkit-backface-visibility: hidden;             backface-visibility: hidden;             position: absolute;             top: 0;             left: 0;             width: 100%;             height: 100%;             border-radius: 0.5rem;             visibility: visible;         }          .card-back {             background: rgb(55, 116, 75);             -webkit-transform: rotateY(180deg);             transform: rotateY(180deg);             display: grid;             place-items: center;         }          .card:hover .card-front {             -webkit-transform: rotateY(-180deg);             transform: rotateY(-180deg);         }          .card:hover .card-back {             -webkit-transform: rotateY(0);             transform: rotateY(0);         }          .card-info {             padding: 1rem 1.5rem;         }          .card-front img {             height: 13rem;             -o-object-fit: cover;             object-fit: cover;             height: 500px;         }     </style> </head>  <body>     <div class="section blog">         <div class="card">              <!-- front of the card -->             <div class="card-side card-front">                 <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20201113113041/paintorder1.png"                     alt="" />             </div>              <!-- card back  -->             <div class="card-side card-back">                 <button class="btn">                     Read More                 </button>             </div>         </div>     </div> </body>  </html> 

Output:


2. Text Moving Up & Down: In this animation, the text will go up on hovering the mouse to it, and in the case of mobile on click, the text will go up.

Explanation: At first, the down texts are being covered using the overflow is hidden and bottom negative value. And when we are hovering into the card the front text is going up using translateY negative values and down text is shown by making the bottom value as zero. Linear-gradient is used to read the text clearly. Transition plays a big part as it makes things going smoothly. The rest of the code is just for styling and for making things good.

Below is the example that illustrates the Text Moving Up & Down animation.

Example:

HTML
<!DOCTYPE html> <html lang="en">  <head>     <style>         .services-container {             max-width: 600px;             margin: 0 auto;             color: #e0e2db;             background: url( https://media.geeksforgeeks.org/wp-content/uploads/20201113113041/paintorder1.png);             background-position: center;             background-size: cover;             background-repeat: no-repeat;         }          .service-item {             overflow: hidden;             position: relative;             padding: 80px;         }          .service-item-black {             background: linear-gradient(                 rgba(0, 0, 0, 0.7),                  rgba(0, 0, 0, 0.7)             );         }          .front-text {             text-align: center;             transition: transform 2s;         }          .back-text {             position: absolute;             bottom: -15em;             width: 75%;             margin: 0 auto;             height: 100%;             transition: bottom 2s;             padding: 15px 0;         }          .back-text h1 {             margin-bottom: 20px;         }          .back-text button {             margin-top: 20px;             padding: 10px 20px;             background: transparent;             border: 2px solid #30804b;             font-size: 20px;             color: #30804b;         }          .back-text button:hover {             background-color: #30804b;             color: #191716;         }          .service-item:hover .front-text {             transform: translateY(-200px);         }          .service-item:hover .back-text {             bottom: 0;         }     </style> </head>  <body>     <div class="services-container">         <article class="service-item         service-item-black">             <div class="front-text">                 <h1>Geeks For Geeks</h1>             </div>              <div class="back-text">                 <h1>Geeks For Geeks</h1>                  <p>                     A Computer Science portal for geeks.                     A Computer Science portal for geeks.                     A Computer Science portal for geeks.                 </p>                  <button type="button">Read More</button>             </div>         </article>     </div> </body>  </html> 

Output:

3. Text Coming up on Hovering: In this animation text coming up on hovering to the image and the image is zoomed.

Explanation: The first is to make the text disappear which is done by making opacity zero. Now on hovering the image the image will be zoomed and the overflow hidden property makes sure that the outer part of the image when it is zoomed doesn't go outside of the certain height and width. And on hovering making the opacity of the image text one makes it visible. Transition property just made things smoother.

Below is the example that illustrates the Text Coming up on Hovering animation.

Example:

HTML
<!DOCTYPE html> <html lang="en">  <head>     <style>         #projects {             padding: 20px 0 80px 0;             background-color: #e0e2db;         }          .projects-container {             max-width: 40vw;             margin: 0 auto;         }          .projects-item {             position: relative;             background: linear-gradient(                 rgba(0, 0, 0, 0.9),                  rgba(0, 0, 0, 0.9)             );             color: #e0e2db;             overflow: hidden;             margin: 10px 0;         }          #projects img {             width: 100%;             min-height: 100%;             transition: transform 2s;             display: block;         }          .img-text {             position: absolute;             top: 50%;             left: 50%;             transform: translate(-50%, -50%);             text-align: center;             opacity: 0;             transition: opacity 4s;         }          .img-text h1 {             font-size: 40px;             margin-bottom: 10px;         }          .img-text h6 {             font-size: 20px;         }          .projects-item:hover img {             opacity: 0.4;             transform: scale(1.3);         }          .projects-item:hover .img-text {             opacity: 1;         }     </style> </head>  <body>      <div id="projects">         <div class="projects-container">             <article class="projects-item">                 <img alt="image"                     src= "https://media.geeksforgeeks.org/wp-content/uploads/20201113113041/paintorder1.png">                 <div class="img-text">                     <h1>GeeksforGeeks</h1>                      <h6>                         It is a computer Science                         portal for geeks.                     </h6>                 </div>             </article>         </div>     </div>  </body>  </html> 

Output:


Next Article
Rubber Band Text animation using HTML and CSS

S

shreasikhan2
Improve
Article Tags :
  • Technical Scripter
  • Web Technologies
  • Web Templates
  • Technical Scripter 2020

Similar Reads

  • Text Animation using HTML & CSS @keyframes Rule
    Text animation is a powerful tool for creating visually engaging and interactive web pages. HTML and CSS offer a range of options for creating advanced text animation effects. In Particular, the CSS '@keyframes' rule comes in handy. The CSS '@keyframes' rule is used to define animations that change
    3 min read
  • Rubber Band Text animation using HTML and CSS
    Rubber Band Text animation refers to a CSS effect where text appears to stretch and bounce back, resembling a rubber band. This playful animation adds dynamic visual interest to text, often achieved using CSS keyframes for smooth, elastic-like transitions on hover or load. Creating Structure: In thi
    3 min read
  • Pulsing Heart Animation Effect Using HTML & CSS
    This article will teach you about widely fascinated and used HTML & CSS animation i.e. Pulsating Heart Animation. In this article, basically we will learn two methods to implement the animation. This animation is beneficial while making footer of the most website with some common text like Made
    7 min read
  • How to pause/play animation using CSS ?
    CSS helps to animate HTML elements without using JavaScript. You can play and pause the animation applied to HTML elements using animation-play-state property of CSS. The animation-play-state property has 2 values:paused - Pauses an ongoing animation.running - Starts a paused animation (default valu
    2 min read
  • Create a Letter-Spacing Animation Effect using HTML and CSS
    In this article, we are going to create a letter-spacing animation using CSS. Letter spacing is the available space between the letters in a particular word, we will walk through each step to achieve this animation effect for our web page. Approach: Initially, letter-spacing will be -15px.At 20%, le
    2 min read
  • Text Typing Animation Effect using HTML CSS and JavaScript
    To create a text-typing animation effect, we will use a combination of HTML structure, CSS animations, and JavaScript logic to create the typing and deleting text like effect. [GFGTABS] HTML <!-- index.html --> <html> <head> <link rel="stylesheet" href="styles.css
    2 min read
  • Shake a Button on Hover using HTML and CSS
    The shake button effect also known as the wiggle effect can be used to make the website look more responsive and dynamic. This is one of the best effects to understand the concept of @keyframes rule in CSS. Approach: The shake button effect or animation can be created using HTML and CSS, First, we w
    2 min read
  • Create Scanning Animation Loader using HTML & CSS
    In this article, we will learn how to create a Scanning Animation. This can be used to add interactivity to the loader page. This is approached by simple HTML & CSS.  Glimpse of the Project: Approach: We will first create an HTML file in which we are going to add a div for adding a span in it.We
    2 min read
  • How to create a progress bar animation using HTML and CSS ?
    In this mini Web Development project we will utilize CSS animations and create a progress bar using them. The progress bar will start from zero and go to a certain extent as we want. The progress bar is basically showing the expertise of a programmer in different languages in animated form. Prerequi
    3 min read
  • How to Create Typewriter Animation using HTML and CSS ?
    A typewriter animation simulates the appearance of text being typed out letter by letter, using only HTML and CSS. This effect is a simple yet eye-catching way to bring dynamic text to life on a website, capturing attention without the need for JavaScript. It's a great technique to make key text ele
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences