×

Create a 3D text effect using HTML and CSS

A3D text effect is a beautiful and attractive part of a webpage. As a web page developer, it is crucial to know how to create a 3D text effect with the help of HTML and CSS. The full form of HTML is HyperText Markup Language. The full form of CSS is Cascading Style Sheet. To create 3D text effect is one of the attractive, easy and simple methods.

Approach

This effect is designed by the text-shadow development. The main thing behind this article is to give the web page 3D look. 

HTML code-

In this portion, we give <h1> tag to the word we will provide 3D design.

<!DOCTYPE html>
<html lang="en">


<body>
<h1>javaTpoint</h1>
</body>


</html>

CSS code-

*,
*::before,
*::after {
 box-sizing: border-box;
}


:root {
 --color-primary: #f6aca2;
 --color-secondary: #f49b90;
 --color-tertiary: #f28b7d;
 --color-quaternary: #f07a6a;
 --color-quinary: #ee6352;
 /*
 --color-primary: #5192ED;
 --color-secondary: #69A1F0;
 --color-tertiary: #7EAEF2;
 --color-quaternary: #90BAF5;
 --color-quinary: #A2C4F5;
 */
}


body {
 min-height: 100vh;
 font-family: canada-type-gibson, sans-serif;
 font-weight: 300;
 font-size: 1.25rem;
 display: flex;
 flex-direction: column;
 justify-content: center;
 overflow: hidden;
 background-color: #eff8e2;
}


.content {
 display: flex;
 align-content: center;
 justify-content: center;
}


.text_shadows {
 text-shadow: 3px 3px 0 var(--color-secondary), 6px 6px 0 var(--color-tertiary),
 9px 9px var(--color-quaternary), 12px 12px 0 var(--color-quinary);
 font-family: bungee, sans-serif;
 font-weight: 400;
 text-transform: uppercase;
 font-size: calc(2rem + 5vw);
 text-align: center;
 margin: 0;
 color: var(--color-primary);
 //color: transparent;
 //background-color: white;
 //background-clip: text;
 animation: shadows 1.2s ease-in infinite, move 1.2s ease-in infinite;
 letter-spacing: 0.4rem;
}


@keyframes shadows {
 0% {
 text-shadow: none;
 }
 10% {
 text-shadow: 3px 3px 0 var(--color-secondary);
 }
 20% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary);
 }
 30% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary), 9px 9px var(--color-quaternary);
 }
 40% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary), 9px 9px var(--color-quaternary),
 12px 12px 0 var(--color-quinary);
 }
 50% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary), 9px 9px var(--color-quaternary),
 12px 12px 0 var(--color-quinary);
 }
 60% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary), 9px 9px var(--color-quaternary),
 12px 12px 0 var(--color-quinary);
 }
 70% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary), 9px 9px var(--color-quaternary);
 }
 80% {
 text-shadow: 3px 3px 0 var(--color-secondary),
 6px 6px 0 var(--color-tertiary);
 }
 90% {
 text-shadow: 3px 3px 0 var(--color-secondary);
 }
 100% {
 text-shadow: none;
 }
}


@keyframes move {
 0% {
 transform: translate(0px, 0px);
 }
 40% {
 transform: translate(-12px, -12px);
 }
 50% {
 transform: translate(-12px, -12px);
 }
 60% {
 transform: translate(-12px, -12px);
 }
 100% {
 transform: translate(0px, 0px);
 }
}

Output:

Create a 3D text effect using HTML and CSS

Example 2-

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>


<style media="screen">
body {
background-color: #444;
font-family: sans-serif;
}
div {
width: 800px;
height: 100px;
margin: 200px auto;
perspective: 1000px;
perspective-origin: 50% -200px;
}
h1 {
text-align: center;
text-transform: uppercase;
font-size: 4em;
letter-spacing: 0.1em;
color: #EEE;
animation: rotate 2s ease-in-out alternate infinite;
}
h1:before {
content: attr(data-shadow);
color: transparent;
text-shadow: 0 0 15px #111;
position: absolute;
z-index: -1;
margin: -0.1em 0 0 0;
animation: skew 2s ease-in-out alternate infinite;
transform-origin: bottom;
}
@keyframes rotate {
from {
transform: rotateY(-10deg);
text-shadow: 1px -1px #CCC,
2px -1px #BBB,
3px -2px #AAA,
4px -2px #999,
5px -3px #888,
6px -3px #777;
}
to {
transform: rotateY(10deg);
text-shadow: -1px -1px #CCC,
-2px -1px #BBB,
-3px -2px #AAA,
-4px -2px #999,
-5px -3px #888,
-6px -3px #777;
}
}
@keyframes skew {
from {
transform: scaleY(0.3) skewX(-15deg);
}
to {
transform: scaleY(0.3) skewX(-20deg);
}
}


</style>
</head>
<body>
<div>
<h1 data-shadow="3D Text Effect">
3D Text Effect
</h1>
</div>


</body>
</html>

Output:

Create a 3D text effect using HTML and CSS

Related Topics

CSS Padding

CSS Padding: The padding property in CSS is addressed to describe the space among the element border and the element content.This property is quite different from the margin property of...

2 minutes read.

CSS Comments

CSS Comments: Generally, comments in CSS are used to describe our code. Further, it will provide support to many users who are concerned with the code. Somewhat, these are ignored...

2 minutes read.

CSS Pseudo-elements

Pseudo-elements The pseudo-classes in CSS can be represented as any keyword which is connected to the selector that represents any selected element’s unique state. On the other hand, pseudo-elements can be...

6 minutes read.

How to edit CSS in WordPress

Developing a new website or blog is a difficult undertaking. We want to create something that the consumers will adore, but we might not want the setting to take months and...

7 minutes read.

Internal CSS

What is CSS? CSS stands for Cascading Style Sheet.CSS is used to apply styling the HTML elements.With CSS user can add or change color, font-size and font-family. It also helps user...

4 minutes read.

CSS calc()

CSS calc(): The CSS calc() function is a CSS function of inbuilt type, which permits us to implement calculations. It is used for calculating the angle, integer frequency, number, time,...

3 minutes read.

Is CSS a programming language?

 A programming language is a set of grammatical rules and a vocabulary for commanding a machine to accomplish specified tasks. High-level languages like BASIC, C, C++, COBOL, Java, FORTRAN, Ada...

4 minutes read.

How to resize an image in CSS

How to resize an image in CSS? The resize image attribute is used in responsive web design to resize images to fit within the div container automatically. The resize image attribute...

3 minutes read.

CSS Position

CSS Position: The position property in CSS is applied to set the position of the elements. It can be used to position the backside of an element. It is also...

3 minutes read.

CSS Button Style

CSS button style: Using CSS properties, we can easily modify the default BUTTON and enhance its appearances using simple graphic commands. TYPES OF BUTTON STYLE: - Program to change button using CSS ...

35 minutes read.

CSS Gradient

CSS Gradient: The CSS gradient property is applied to show the smooth transition inside two specified colors or more than two specified colors. Need of CSS Gradient The following are a few...

4 minutes read.

CSS Sticky

CSS Sticky The position property in CSS is applied to set an element’s position. This property is also applied to position an element behind the other element. It is useful for...

1 minute read.

CSS Font

CSS Font: CSS has font property, which makes the text more attractive. We can alter the entire look by changing font color, font size, font style, and much more. In...

5 minutes read.

CSS Page-break-before Attribute

Page-break-before Attribute As its name implies, the page-break-before property is applied to include page break before any element, at the time of printing any document. It adds the page break before...

5 minutes read.

CSS Display

CSS Display: The CSS Display property is one of an essential property among all other properties of CSS. The display property specifies how the HTML elements should be displayed on...

4 minutes read.

CSS Page-break-after Attribute

Page-break-after Attribute As its name implies, the page-break-before property is applied to include page break after any element, at the time of printing a document. It adds the page break after...

5 minutes read.

CSS Text-stroke

Text-stroke Text-stroke CSS property inserts the stroke to any text and gives a decoration option to them also. It describes the stroke’s width and color for various text characters. It is...

2 minutes read.

CSS Reference

The CSS Reference lists all of the basic standard CSS properties, pseudo-classes, pseudo-elements, and data types, for all intents and purposes functional notations, and at-rules alphabetically.  The site also includes...

5 minutes read.

CSS Text Effects

Text Effects in CSS We can use distinct text effects used inside the HTML document. Few attributes can be applied to insert the text effects. We can also style various web documents...

5 minutes read.

How to change font size in CSS

How to change font size in CSS? Font Size: - Users may attract attention to content on a website page in various ways. One element in a sentence can be highlighted. You...

5 minutes read.