🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
Introduction
Creating a 3D text effect in CSS can add depth and make your text stand out. This effect can be achieved using the text-shadow property to simulate depth by adding multiple layers of shadows.
In this tutorial, you'll learn how to create a 3D text effect using CSS by applying multiple shadows to mimic a 3D appearance.
Problem Statement
Create a CSS code that:
- Adds a 3D effect to text using the
text-shadowproperty. - Demonstrates how to adjust shadow positioning to create the 3D illusion.
Example:
- Input: A heading element with the text "3D Text Effect".
- Output: The text appears with a 3D effect, as if popping out of the screen.
Solution Steps
- Use
text-shadowProperty: Apply multiple shadows to simulate depth and create a 3D effect. - Adjust Shadow Offsets: Use varying offsets and shadow colors to create the illusion of 3D text.
HTML Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Text Effect</title>
<style>
/* Step 1: Create a 3D effect using text-shadow */
.three-d-text {
font-size: 4rem;
color: #f39c12;
text-shadow:
2px 2px 0 #e74c3c, /* Red shadow */
4px 4px 0 #c0392b, /* Darker red shadow */
6px 6px 0 #8e44ad, /* Purple shadow */
8px 8px 0 #2c3e50; /* Dark blue shadow */
font-family: Arial, sans-serif;
}
/* Center the text for better presentation */
.container {
text-align: center;
margin-top: 100px;
}
</style>
</head>
<body>
<div class="container">
<h1 class="three-d-text">3D Text Effect</h1>
</div>
</body>
</html>
Explanation
Step 1: Use text-shadow for 3D Effect
To create a 3D effect, apply multiple shadows with varying offsets and colors:
.three-d-text { font-size: 4rem; color: #f39c12; text-shadow: 2px 2px 0 #e74c3c, /* Red shadow */ 4px 4px 0 #c0392b, /* Darker red shadow */ 6px 6px 0 #8e44ad, /* Purple shadow */ 8px 8px 0 #2c3e50; /* Dark blue shadow */ }The
text-shadowproperty uses multiple shadows to simulate the depth and dimension of the text. Each shadow has increasing offsets to create the illusion of 3D text, with varying colors for a layered effect.
Step 2: Adjust Shadow Offsets and Colors
- You can customize the 3D effect by adjusting the offsets (e.g.,
2px 2px,4px 4px, etc.) and shadow colors. This allows you to experiment with different levels of depth and styles.
Output
Conclusion
Creating a 3D text effect in CSS is easy using the text-shadow property. By adding multiple layers of shadows with varying offsets and colors, you can give your text a three-dimensional appearance, adding depth and making it stand out on your web page.
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business

Comments
Post a Comment
Leave Comment