Forum Moderators: not2easy
setting margin-left & margin-right: auto on a layer usually centres it, or you could use position: absolute and declare the percentage of the window it should start at, and so on (hence, a layer with width: 50%, positioned at left: 25%, should centre.)
There's also the old text-align: center in the body element, to centre everything.
Glancing at my styles, those are the only ones I can see being used, to probably varying degrees of success.
with pure CSS it's not very easy and there are many posts on this thread which explore different methods.
If you are a "table-less" fan then don't read any further ;)
If you're still reading then Yes it can be done but you need to use one teency weency table to "help" until CSS gets it right.
CSS:
body{
margin: 0;
padding: 0;
}
/* treat this as your new "body" tag */
table.container{
width: 100%;
height: 100%;
font-family: verdana, tahoma, arial, sans-serif;
font-size: 1em;
color: white;
background-color: black;
}
td.centered{
text-align: center;
vertical-align: center;
padding: 0 3em; /* adjust to suit */
}
#content{}
HTML:
<body>
<table class="container"><tr><td class="centered">
<div id="content">
<p>Your content here</p>
</div>
</td></tr><table>
</body>
note: the td.centered is required as the table will not accept the vertical-align property
(sorry tableless fans ;))
Suzy
<added> CSS padding note </added>
Indeed, IE and NS6 support an attribute called vertical-align which supports 8 different variables. Sadly, vertical-align isn't a w3c standard, and I strive to conform to that, regardless. Opera 6 and Mozilla variants are left out in the cold. And as I type this - having been fiddling with a test, it seems Mozilla doesn't actually support the CSS2 height variable.
I've not really fiddled with it then, as such, but the variables are:
baseline
sub
super
top
middle
bottom
text-bottom
text-top
Of course, with a little work, its possible to hash together vertical satisfaction by way of the position: style.
I think I'm somehow coming around to proving its a retched thing to deal with.