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
  • CSS Tutorial
  • CSS Exercises
  • CSS Interview Questions
  • CSS Selectors
  • CSS Properties
  • CSS Functions
  • CSS Examples
  • CSS Cheat Sheet
  • CSS Templates
  • CSS Frameworks
  • Bootstrap
  • Tailwind
  • CSS Formatter
Open In App
Next Article:
Design a Frosted Glass Effect using HTML and CSS
Next article icon

Design a Rotating card effect using HTML and CSS

Last Updated : 23 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Rotating cards are the effect on cards that will rotate to some degree when you hover your mouse over them. There will be information, links, or images on the card which will be visible when you hover over the cards.

In this article, you’re going to learn how to make rotating cards on your website using only HTML and CSS. 

Example: In this example, we will design a rotating card effect using HTML and CSS.

Step-by-step implementation:

Step 1: HTML file for the card

HTML
<!DOCTYPE html> <html> <head>     <meta name="viewport" content=         "width=device-width, initial-scale=1"> </head> <body>     <!-- Give a proper heading-->     <h1 style="color: green; text-align: center;">         GeeksForGeeks Rotating Card     </h1>     <div class="container">         <!-- create a class to build the              structure of card using div-->         <div class="card GFG"></div>     </div> </body> </html> 

Step 2: Decorating the front of the card using CSS: We have built the structure of the first face of the card in the HTML part. Now we need to design the card with different CSS properties and the key is to use the transform property of CSS and rotate the card by 45 degree i.e. transform: rotate(45deg). So, now add the below written CSS code inside head tag.

CSS
.card {     position: absolute;     width: 200px;     height: 200px;     display: inline-block;     border-radius: 10px;     padding: 15px 25px;     box-sizing: border-box;     cursor: pointer;     margin: 10px 15px;     transition: transform 0.5s;     background-position: right;     background-size: cover;     transform: rotate(45deg); } .GFG {     margin-top: 170px;     margin-left: 600px;     background-image: url(gfg.jpg); }  .card:hover {     transform: translateY(-10px); } 

Note: You can rotate your cards as much as possible depending on the transform: rotate(45deg) and the background-image is in images folder and we will access that image using url() and this url() will take the address of the saved image.

Example: Complete HTML code is given as an example for your help. This example uses the transform: rotate(45deg) property to rotate the card.

HTML
<!DOCTYPE html> <html>  <head>     <meta name="viewport"            content="width=device-width, initial-scale=1">     <!-- CSS code -->     <style>         .card {             position: absolute;             width: 200px;             height: 200px;             display: inline-block;             border-radius: 10px;             padding: 15px 25px;             box-sizing: border-box;             cursor: pointer;             margin: 10px 15px;             transition: transform 0.5s;             background-position: right;             background-size: cover;             transform: rotate(45deg);         }         .GFG {             margin-top: 170px;             margin-left: 600px;             background-image: url( https://media.geeksforgeeks.org/wp-content/uploads/20230530074745/gfg.png);         }         .card:hover {             transform: translateY(-10px);         }     </style> </head>  <body>     <!-- Give a proper heading-->     <h1 style="color: green; text-align: center;">         GeeksForGeeks Rotating Card     </h1>     <div class="container">         <!-- Create a class to build the              structure of card using div-->         <div class="card GFG"></div>     </div> </body>  </html> 

Output:

https://media.geeksforgeeks.org/wp-content/uploads/20240722164409/Animation.mp4


Next Article
Design a Frosted Glass Effect using HTML and CSS

R

riyamathur
Improve
Article Tags :
  • CSS
  • HTML
  • Technical Scripter
  • Web Technologies
  • CSS-Questions
  • HTML-Questions
  • Technical Scripter 2020

Similar Reads

  • Design a Flip Card Effect using ReactJS
    Design a Flip Card Effect using ReactJS refers to adding flip animations to the react component. The flip card effect is where a card flips to reveal its backside when clicked or hovered over. PrerequisitesReact JSNode.js & NPMTable of Content Approach 1: Using CSS stylingApproach 2: Using react
    4 min read
  • Design a Frosted Glass Effect using HTML and CSS
    In this article, we will implement a frosted glass effect using the bootstrap 4 card class. The below image is the final output that you will get as the final result of this article. Approach: 1. Styling the body: Let's first set the background for your webpage. Write the below code under your head
    2 min read
  • How to create rotating disc effect using CSS?
    The Rotating Disc Effect also known as Overlapping Disc Effect is a type of illusion effect that can be used for various purposes on a website. It can be used in anything from a loader sticker to creating an illusion for the user. It is called overlapped disc because there are many overlapped discs
    3 min read
  • Design a Image Hover Effect Color Transition template using HTML and CSS
    The article uses HTML and CSS to create the template for an Image Hover Effect with Color Transition. This template adds an interactive element to your web design by smoothly transitioning colors when users hover over an image. You can create a dynamic effect that enhances visual engagement by utili
    2 min read
  • Create a Reverse Scrolling Effect using HTML and CSS
    Creating an attractive UI with a reverse scroll effect can be an engaging design. The Reverse Scrolling effect facilitates a unique and visually interactive experience for users, which breaks the conventional top-down scrolling system to which the user is accustomed. In this article, we'll create a
    2 min read
  • How to design Animated Product Card Template using HTML and CSS ?
    In the dynamic world of web development, where creating engaging and visually appealing user interfaces is key, one effective strategy to captivate your audience involves seamlessly incorporating animated elements into your design. In this article, we will guide you through the process of creating a
    3 min read
  • Designing a Working Table Fan using HTML and CSS
    In this article, we will design a Working Table-fan using HTML and CSS. List of HTML tags used: Polyline: The <polyline> element is used to create the HTML <svg> element which is a container for SVG graphics any shape that consists of only straight linesdiv: The <div> tag defines a
    2 min read
  • Design a Virtual Credit Card Template using HTML and CSS
    In this article, we will design a Virtual Credit Card template using HTML and CSS for a modern and interactive user experience. This design includes spaces for the card number, name, and expiry date. HTML will be used to structure the layout, while CSS will add styling for a visually pleasing and be
    3 min read
  • Design Animated Google Loader using HTML and CSS
    The Google Loader consists of 4 circles with blue, red, yellow, and green colors. You can easily create them using HTML and CSS, and animate them to move the same as in the final output. The animation is just translating the circle in the Y axis with .25s time delay. For non-stop and fluid animation
    2 min read
  • Responsive Card with hover effect using HTML and CSS
    Cards are very important part for any website. It is used to display some important information in short to viewers. So, in this article, we will create a  responsive card with amazing hover effect using HTML and CSS. By using HTML we will design the basic structure of the card and then by using the
    4 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