Layers in CSS Tutorial
Standard HTML doesn't make it easy to place objects in exactly the right place.
You can do so with imaginative use of tables, but there are situations in which
it is not possible to do so. Other times you may need to place a particular image
on top of another part of your web page.
1. A basic object which uses CSSWe'll start with a tag whose size and appearance we'll define using CSS.
In this example we've used a 2. Turning the object into a layer
We can turn this into a layer with only one additional line of code. Within the CSS definition for the
You'll notice that this layer is now "floating" on top of the text. It no longer occupies space above the text and the text moves up. On Mozilla the layer will move into the top left corner, waiting to be moved somewhere. 3. Positioning the layer
Once we've created a layer, we'll need to specify its position. We can do this with X and Y coordinates which both extend from the top left corner.
We'll move the layer to the right side of the page's main heading with this code:
Using layers in this way is a natural means of producing a menu system, which always has parts of the HTML overlapping others.
Additionally it allows a great deal more control of exactly where an element is placed. Using this, we can make sure our
menu bar is exactly where it should be, and it can be made to line up with another image very easily.
4. Using relative positioning
Absolute positioning will always position an element from the very top left of a page. This is useful for moving things about
that naturally appear at the top of the page. However it isn't so great for moving things further down the page as they may well
end up lying on top of text. There is another scheme we can use, called
|