Japan Interface

Centering page content without tables

As web designers are gradually encouraged to abandon tables for page layout and switch to CSS (Cascading Style Sheets), one of the first problems they run in to is how to centre their design in the browser window regardless of screen size. Setting the margins of a positioned <div> (or layer, as Dreamweaver calls it) to "auto" should do the trick, but as so often happens, this method is not supported by all browsers.

Layout Designer 2 to the rescue

Fortunately for Dreamweaver users, Project Seven provides a free extension that solves this problem — and does a lot more besides. It's called Layout Designer 2 (LD2), and you can get the latest version with full instructions direct from PVII. As it's such a powerful extension, some people find it rather overwhelming. Others assume that LD2 does everything automatically, and can't understand when it doesn't work. That's not because of faults in the extension itself — far from it — but you do need to make sure you follow correct coding practice for Layout Designer 2 to do its job properly. The purpose of this brief tutorial is to help you avoid some of the most common problems that people run in to.

What LD2 actually does

Layout Designer 2 is actually two Dreamweaver behaviours in one:

The first positions Dreamweaver layers (divs) wherever you want in relation to the screen. The second positions layers in direct relationship to each other.

Both work in exactly the same way. LD2 searches for the top and left coordinates of each layer, measures the size of the screen, calculates the new position for each layer, and finally moves them there. Often, particularly on a slow connection, you can actually see the layers jump across the screen. Although impressive, it's not very elegant — but there is an easy solution (we'll come to that later).

So, for LD2 to be able to work its magic, it needs to know:

Layout Designer 2 uses JavaScript to rearrange elements dynamically on the page, and when things don't work they way you expect, it's normally because of incorrect code in your original web page. Browsers often ignore minor errors in code on static pages, but once you make your pages dynamic, even the smallest mistake can stop things working.

Two other problems are specific to Layout Designer 2, and stem from misunderstandings about how it works:

Centering multiple layers...

© 2002-3, Japan Interface. All rights reserved.