15. Layers

Layers can give your page a 3D look by letting you stack images or with JavaScript to make a pop up menu. There a many other uses for layers as well, however I guess I need to get on with showing you how to make them.

A layer tag looks like this <layer> </layer>. You place a layer using the top and left attribute which is the distance from the top left corner of the screen and it is in pixels. Use the height and width to dimension the layer. The default location is the top left corner of the screen and the default size is equal to whatever you put in. You can add text or images to the layer just by pacing it in the layer tags. In fact, you can add anything you can put on a page including tables, links or whatever. The background color and image use the same attributes as the body tag. Try the example below to see how it works. Then try changing the size, color, placement, dimensions and content of the layers.Here's an example of how to use layers to stack picures.

 

<Layer ID="layer1" Top="5" Left="5">
<IMG SRC="mountian1.jpg" WIDTH="250" HEIGHT="175"
BORDER="0"></LAYER>
<Layer ID="layer2" Top="15" Left="240">
<IMG SRC="mountian2.jpg" WIDTH="250" HEIGHT="175"
BORDER="0"></LAYER>
<LAYER ID="layer3" TOP="155" LEFT="15">
<IMG SRC="mountian3.jpg" WIDTH="250" HEIGHT="175"
BORDER="0"></LAYER>
<LAYER ID="layer4" TOP="170" LEFT="245">
<IMG SRC="mountian4.jpg" WIDTH="250" HEIGHT="175"
BORDER="0"></LAYER>

The you could add links to show a larger picture when clicked.

<Layer ID="layer1" Top="5" Left="5">
<A HREF="../images/mountian1.jpg">
<IMG SRC="../images/mountian1.jpg" WIDTH="250" HEIGHT="175" BORDER="0"></A></LAYER>
<Layer ID="layer2" Top="15" Left="240">
<A HREF="../images/mountian2.jpg">
<IMG SRC="../images/mountian2.jpg" WIDTH="250" HEIGHT="175"
BORDER="0"></A></LAYER>
<LAYER ID="layer3" TOP="155" LEFT="15">
<A HREF="../images/mountian3.jpg">
<IMG SRC="../images/mountian3.jpg" WIDTH="250" HEIGHT="175"
BORDER="0"></A></LAYER>
<LAYER ID="layer4" TOP="170" LEFT="245">
<A HREF="../images/mountian4.jpg">
<IMG SRC="../images/mountian4.jpg" WIDTH="250" HEIGHT="175"
BORDER="0"></A></LAYER>

Here's an example of how to make a pop up menu using layers.

<Layer ID="layer1" Top="20" Left="5" bgcolor="#cc00ee" Width="99%">
<h1>Welcome</h1>
</LAYER><Layer ID="layer2" Top="75" Left="5" bgcolor="teal" width="200">
<a href="#" onMouseOver="layer3.visibility='show'";
onMouseOut ="layer3.visibility='hide'";>
<font color="#FFFFFF">Menu 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font></a>
<a href="#" onMouseOver="layer4.visibility='show'";
onMouseOut ="layer4.visibility='hide'";><font color="#FFFFFF">
Menu 2</font></a>
</LAYER>
<LAYER ID="layer3" TOP="93" LEFT="10" BGCOLOR="#6666FF" visibility='hide'></p>
<a href="#" onMouseOver="layer3.visibility='show'";
onMouseOut ="layer3.visibility='hide'";><font color="#FFFFFF">
Item 1</font></a><br>
<a href="#" onMouseOver="layer3.visibility='show'";
onMouseOut ="layer3.visibility='hide'";><font color="#FFFFFF">
Item 2</font></a><br>
<a href="#" onMouseOver="layer3.visibility='show'";
onMouseOut ="layer3.visibility='hide'";><font color="#FFFFFF">
Item 3</font></a><br>
</LAYER>
<LAYER ID="layer4" TOP="93" LEFT="100" BGCOLOR="#FFFFFF" visibility='hide'></p>
<a href="#" onMouseOver="layer4.visibility='show'";
onMouseOut ="layer4.visibility='hide'";>Item 1</a><br>
<a href="#" onMouseOver="layer4.visibility='show'";
onMouseOut ="layer4.visibility='hide'";>Item 2</a><br>
<a href="#" onMouseOver="layer4.visibility='show'";
onMouseOut ="layer4.visibility='hide'";>Item 3</a><br>
</LAYER>

Tags covered in this section.
Layer <LAYER></LAYER>
Name <LAYER ID="***"></LAYER>
Location <LAYER LEFT=? TOP=?></LAYER>
Source File <LAYER SRC="***"></LAYER>
Dimensions <LAYER HEIGHT=? WIDTH=?></LAYER>
Visible? <LAYER VISIBILITY=SHOW|HIDDEN|INHERIT></LAYER>
Background <LAYER BACKGROUND="$$$$$$"></LAYER>
Color <LAYER BGCOLOR="$$$$$$"></LAYER>
Alt. Content <NOLAYER></NOLAYER>