I a template, I have five DIV elements underneath each other on a HTML page. (Logo, top menu, sub menu, content, footer).
I want the user to be able to set the alignment for each DIV in a CMS: left, center, right. Those settings I used to translate to
margin-left: auto; margin-right: 0px; // right
margin-right: auto; margin-left: 0px; //left
margin-left: auto; margin-right: auto; // center
for each DIV. Now however, I want the user to be able to specify a real margin for each side as well. That, of course, makes the margin
attribute unusable for positioning.
I do not want to use float for the positioning as this will bring additional layout troubles. I would have to surround the DIVs with overflow: auto
wrappers and so on.
My current idea is to have two nested DIVs. The outer one takes care of the positioning (margin:auto), while the inner one sets the user-specified margins.
I fear however that this will bring me additional woes when variable widths come into play, or inner padding.
Is there a simpler way than that to align a block element left, right, or center?
IE7 used to listen to <div align=center>
and center block elements surrounded by it. Something like that (but valid and cross-browser) would be exactly what I'm looking for.