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:
Shimmer Effect using CSS
Next article icon

Double Layered Text Effect using CSS

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

The double-layered text effect feature is very new in the world of text-animation targeting animated websites and its users as the audience. The feature basically has two layers for every word and the upper layer can be manipulated by various events such as hover events. The rotation of the upper layer is performed at some certain angle to make a hinge kind of effect. It will look like the upper layer is hinged to the lower layer from a single point.

Approach: The approach is to first create two layers using the before selector and then use hover selector to rotate it on mouse hover.

HTML Code: In this section, we have wrapped each alphabet in a span with a data-title attribute having the same value as of the alphabet.

html
<!DOCTYPE html> <html lang="en">    <head>     <meta charset="UTF-8" />     <meta name="viewport" content="width=device-width, initial-scale=1.0" />     <title>Double Layered Text</title> </head>    <body>     <div class="geeks">         <span data-title="G">G</span>         <span data-title="E">E</span>         <span data-title="E">E</span>         <span data-title="K">K</span>         <span data-title="S">S</span>         <span data-title="F">F</span>         <span data-title="O">O</span>         <span data-title="R">R</span>         <span data-title="G">G</span>         <span data-title="E">E</span>         <span data-title="E">E</span>         <span data-title="K">K</span>         <span data-title="S">S</span>     </div> </body>    </html> 

CSS Code:

  • Step 1: Perform some basic styling like a background, font-family, font-size and adjusting text to center.
  • Step 2: Now use before selector with the content set as the data-title used in the span tag. This will create the second layer of the text. Make sure to provide a different color from the color given to the first layer.
  • Step 3: Now use some transitions to give smooth animation.
  • Step 4: At last, use hover selector to change perspective or in simple words rotate the second layer.

Note: Choose your degree rotation and values for transitions carefully. You can use the browser console to get the perfect values.

CSS
body {             background: black;         }          .geeks {             text-align: center;             margin: 200px auto 0;             font-family: Arial, Helvetica, sans-serif;         }          .geeks span {             font-size: 80px;             font-weight: 700;             color: green;             position: relative;             text-shadow: -1px 0 0 rgba(0, 0, 0, .2);         }          .geeks span::before {             content: attr(data-title);             position: absolute;             top: 0;             left: 0;             transform-origin: left;             color: #fff;             transition: .5s cubic-bezier(0.175, 0.885, 0.32, 1.275);             transform: rotateY(25deg);         }          .geeks span:hover::before {             transform: perspective(1000px) rotate(-67deg);         } 

Complete Code: It is the combination of the above two sections of the code.

HTML
<!DOCTYPE html> <html lang="en">    <head>     <meta charset="UTF-8" />     <meta name="viewport" content="width=device-width, initial-scale=1.0" />     <title>Double Layered Text</title>     <style>         body {             background: black;         }          .geeks {             text-align: center;             margin: 200px auto 0;             font-family: Arial, Helvetica, sans-serif;         }          .geeks span {             font-size: 80px;             font-weight: 700;             color: green;             position: relative;             text-shadow: -1px 0 0 rgba(0, 0, 0, .2);         }          .geeks span::before {             content: attr(data-title);             position: absolute;             top: 0;             left: 0;             transform-origin: left;             color: #fff;             transition: .5s cubic-bezier(0.175, 0.885, 0.32, 1.275);             transform: rotateY(25deg);         }          .geeks span:hover::before {             transform: perspective(1000px) rotate(-67deg);         }     </style> </head>    <body>     <div class="geeks">         <span data-title="G">G</span>         <span data-title="E">E</span>         <span data-title="E">E</span>         <span data-title="K">K</span>         <span data-title="S">S</span>         <span data-title="F">F</span>         <span data-title="O">O</span>         <span data-title="R">R</span>         <span data-title="G">G</span>         <span data-title="E">E</span>         <span data-title="E">E</span>         <span data-title="K">K</span>         <span data-title="S">S</span>     </div> </body>    </html> 

Output:

https://media.geeksforgeeks.org/wp-content/uploads/20240725084416/Double-layered-text.mp4


Next Article
Shimmer Effect using CSS

S

sirohimukul1999
Improve
Article Tags :
  • CSS
  • Web Technologies
  • CSS-Questions

Similar Reads

  • Text Split Effect using CSS
    The Text Split Effect in CSS is a popular and visually engaging technique that breaks up a block of text into individual letters or words, which are then animated or styled separately. This effect can add a creative touch to any webpage, making it dynamic and interactive. In this article, we will ex
    4 min read
  • Loading Text Animation Effect using CSS
    There are a lot of animations possible in CSS and today we will look at the loading text animation. The basic idea behind the working of this animation is the application of animation delay. Every alphabet is delayed by .1s so that each alphabet animates with a little delay and give the loading anim
    3 min read
  • Fading Text Animation Effect Using CSS3
    The fading text animation effect is one of the most demanding effects on UI/UX designing. This effect can be achieved by using HTML5 and CSS3. In the fading text effect, whenever we load the window, the text will slowly start disappearing. We can implement this effect using the animation property in
    2 min read
  • Shimmer Effect using CSS
    A Shimmer Effect is much in trend to produce an illusional glass effect on articles, texts, or images. This might seem a very extravagant property from only some CSS frameworks but the fun part is we can do it using CSS and its properties very easily. First of all, create a div container with an art
    2 min read
  • How to Create Embossed Text Effect using CSS ?
    The embossed text effect creates a 3D illusion, making text appear raised or pressed into the page. Using CSS, this effect is achieved by applying contrasting text-shadow values that simulate light and shadow, giving the text a visually elevated or indented appearance. Approach:Basic HTML Structure:
    2 min read
  • How to specify the double border using CSS ?
    The task is to specify the double border using CSS. In this article, we are going to use the border-style property to style the border. we have two common methods border-style property style and outline property in CSS. Property used: border-style property: This property is used to set the style of
    2 min read
  • Text portrait using CSS
    Text portraits are a fascinating way to blend typography and visual art. In this article, we will learn to create a text portrait using CSS in a few simple steps. If you want to know, then keep reading this article. We have specified all the steps you need to take. So let's start designing the text
    2 min read
  • Self-Typing Text Effect using CSS & JavaScript
    Self-Typing Text Effect is a type of effect in which all the alphabets of the text are revealed one by one, one after the other to give the look and feel of being typed on the screen by themselves. Even though this is a basic text effect, it is still eye-capturing and effective animation. This anima
    5 min read
  • How to Apply Shadow Effect on Text Using CSS?
    The CSS text-shadow property is used to add a shadow to the text. Adding a shadow to text using CSS text-shadowThe text-shadow property of CSS is used to apply the shadow effect on text. It takes four values verticalShadow, horizontalShadow, blur, and color. Syntax text-shadow: verticalShadow horizo
    1 min read
  • How to Get Text-Wrapping Effect using CSS ?
    In this article, we are going to learn how to achieve a text-wrapping effect with CSS. In web design, we create visually appealing and readable text that is essential for engaging user experiences. One effective technique to enhance the readability and aesthetics of text is by implementing a text-wr
    3 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