CSS Tutorials

Layers In CSS
Previous Home Next

With CSS, it is possible to work with layers: pieces of HTML that are placed on top of the regular page with pixel precision.CSS gives you opportunity to create layers of various divisions. The CSS layers refer to applying the z-index property to elements that overlap with each other.The z-index property is used alongwith position property to create an effect of layers. You can specify which element should come on top and which element should come at bottom.

The advantages of this are obvious - but once again Netscape has very limited support of CSS layers - and to top it off: the limited support it offers is quite often executed with failures.n CSS, each element is given a priority. HTML elements that appear later in the source code than others will have a higher priority by default. If there are two overlapping CSS positioned elements, the element with the higher priority will appear on top of the other.To manually define a priority, set the z-index value. The larger the value, the higher the priority the element will have.

Simple Example
<html>
<head>
<style>
h4{ position: relative; 
top: 30px;
left: 50px;
z-index: 2;
background-color: #336699;}
p { position: relative; 
z-index: 1; 
background-color: #FFCCCC;} 
</style>
</head>
<body>
<h4>Header Z-Index = 2<br>
This is used to show first part</h4>
<p>You probably can't read this part,
 so I will fill it in with useless text for 
the time being.<br>This paragraph has a z-index
 of 1, which is less than
the header.<br>As you can see, the header has 
been moved down, using positioning, and is
now resting on top of this paragraph.<br>If we
 had not defined the z-index, by default the 
 paragraph would have been on top<br> of the header 
 because it appears later in our HTML code.</p>
</body>
</html>

Output

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: