In this article, we are going to create an illusion of images below the main image. This is a simple article, we can achieve our target only by using HTML & CSS.

Approach: Create a main div in which we have added a heading tag and then use the selectors in CSS to create the effects.
HTML Code:
- First, we create an HTML file(index.html).
- After creating the HTML file, we are going to give a title to our webpage using the <title> tag. It should be placed inside the <head> tag.
- Then we link the CSS file that provides all the animations effect to our HTML. It is also placed inside the <head> tag.
- Coming to the body section of our HTML code.
- Firstly, we are giving a heading to our page.
- Inside the heading create 3 span to store the data.
Example: In this example, we will create perspective text.
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< link rel = "stylesheet"
href = "style.css" >
</ head >
< body >
< h1 >
< span >geeks</ span >
< span >for</ span >
< span >geeks</ span >
</ h1 >
</ body >
</ html >
|
CSS Code: CSS is used to give different types of animations and effects to our HTML page so that it looks interactive to all users. In CSS, we have to remember the following points-
- Restore all the browser effects.
- Use classes and ids to give effects to HTML elements.
- Use of selectors to select different elements!
CSS
*{
margin : 0 ;
padding : 0 ;
box-sizing: border-box;
}
body{
height : 100 vh;
margin : 0 ;
display : flex;
justify- content : center ;
align-items: center ;
background : #000 ;
color : teal ;
}
h 1 {
width : 3em ;
height : 1em ;
font-size : 6em ;
position : relative ;
white-space : nowrap ;
color : transparent ;
}
h 1 span{
position : absolute ;
background-color : rgb ( 7 , 138 , 138 );
color : #000 ;
}
span:nth-child(odd){
transform: skew( 50 deg, -20 deg) scaleY( 0.75 );
}
span:nth-child(even){
transform: skew( -5 deg, -20 deg);
}
span:nth-child( 1 ){
bottom : 1em ;
left : 0.5em ;
}
span:nth-child( 2 ){
top : 0.5em ;
left : 2em ;
}
span:nth-child( 3 ){
top : 2em ;
left : 2.5em ;
}
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
01 Jun, 2023
Like Article
Save Article