- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a flip box with CSS?
To create a flip box with CSS, the code is as follows −
Example
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin:20px; } .flipCard { background-color: transparent; width: 300px; height: 300px; perspective: 1000px; } .innerCard { position: relative; width: 100%; height: 100%; text-align: center; transition: transform 0.6s; transform-style: preserve-3d; box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); } .flipCard:hover .innerCard { transform: rotateY(180deg); } .frontCard, .cardBack { position: absolute; width: 100%; height: 100%; -webkit-backface-visibility: hidden; backface-visibility: hidden; } .frontCard { background-color: rgb(124, 225, 243); color: black; } .cardBack { background-color: #3329b9; color: white; transform: rotateY(180deg); font-size: 18px; font-weight: bold; } </style> </head> <body> <h1>Flip box example</h1> <div class="flipCard"> <div class="innerCard"> <div class="frontCard"> <h1>Front Text</h1> </div> <div class="cardBack"> <h1>Back Text</h1> </div> </div> </div> <h2>Hover over the above card to see the back side</h2> </body> </html>
Output
The above code will produce the following output −
On hovering above the element the element will flip as shown −
Advertisements