CSS layers

CSS Layers

CSS provides the opportunity to create layers of various areas. CSS layers involve applying the z-index property to elements that overlap one another.

The z-index property, used in conjunction with the position property, creates a layered effect. You can specify which element should be at the top and which should be at the bottom.

The z-index property can help you create more complex web page layouts. Below is an example showing how to create layers in CSS.


<html> 
<head> 
</head> 

<body> 
<div style = "background-color:red; 
width:300px; 
height:100px; 
position:relative; 
top:10px; 
left:80px; 
z-index:2"> 
</div> 

<div style = "background-color:yellow; 
width:300px; 
height:100px; 
position:relative; 
top:-60px; 
left:35px; z-index:1;">
</div>

<div style = "background-color:green; 
width:300px; 
height:100px; 
position:relative; 
top:-220px; 
left:120px; 
z-index:3;">
</div>

</body>

</html>

It will produce the following result –

CSS Layer

Leave a Reply

Your email address will not be published. Required fields are marked *