You're on the right track. You're correct that elements normally appear in the order they are declared because they have position:static by default. To stack (or layer) elements, you would generally set all of them to position:absolute, set the z-index on each as desired (to determine which one is on top), and enclose them all in a containing element with it's position set to either 'relative' or 'absolute' and it's width and height set large enough to contain the internal elements.
What trips up most people are two principles of absolute positioning. The first is that elements set to 'position:absolute' are removed from the normal document flow. That means that the position of the other elements on the page does not change to allow room for elements using position:absolute. The second is that elements using position:absolute are positioned relative to their parent positioned element. That is, the position is based on the nearest parent containing element whose position has been explicitly declared in your stylesheet - or, if there are none, the top of the document.
From there, layering is just a matter of managing the z-index setting (which only works on positioned elements!). If you search on "CSS positioning tutorial" you'll find some good advice. It may be confusing at first, but you should soon get the hang of it. Good luck!