NS Table Centering

windows

Guest
Hi,<br />
<br />
Just finished reading past threads on centering tables in NS, and copied the code, but to no avail.<br />
<br />
First of all, I have one master table that All of the content is inside, so that I can have control of page alignment.<br />
<br />
I'm using this <div style="text-align:center;"> master table </div> like so and then for the master table tag as this: <br />
<br />
.table-main<br />
{<br />
text-align: center;<br />
width: 768px;<br />
color: #996633;<br />
background-color: transparent;<br />
}<br />
<br />
with of course: <table class="table-mail" cellpad...><br />
<br />
But it will not center!! It doesn't make any sense, because I've got it to work before. <br />
<br />
Oh yeah, also the CSS for the <body> tag reads as:<br />
<br />
body<br />
{<br />
margin-top: 0px;<br />
margin-left: auto;<br />
margin-right: auto;<br />
padding-top: 0px;<br />
padding-left: auto;<br />
padding-right: auto;<br />
background-image: url(images/able-bg-460x460-j30.jpg);<br />
background-repeat: no-repeat;<br />
background-position: 377px 95px;<br />
background-attachment: fixed;<br />
color: black;<br />
background-color: white;<br />
}<br />
<br />
<br />
Any thoughts to shed some light on this? I've gone through the code looking for errors, yet found none and proceeded to run it thru W3C's validator with no problem.<br />
<br />
EDIT: ...and no I do not want nor will use the <table align="center"><br />
<br />
Thanks,<br />
Gandalf<br />
:D<!--content-->High there Thee Gandalf,<br />
<br />
Here is the code that you need<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br />
<html><br />
<head><br />
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"><br />
<title>Dead Centre Table</title><br />
<style type="text/css" media="screen"><br />
<!--<br />
body <br />
{<br />
background-color: #ffffff;<br />
margin: 0px<br />
}<br />
<br />
#horizon <br />
{<br />
color: white;<br />
background-color: transparent;<br />
position: absolute;<br />
top: 50%;<br />
left: 0px;<br />
width: 100%;<br />
height: 1px;<br />
overflow: visible;<br />
visibility: visible;<br />
display: block<br />
}<br />
<br />
#content <br />
{<br />
background-color: transparent;<br />
margin-left: -384px; /*half the table width */<br />
position: absolute;<br />
top: -238px; /*half the table height */<br />
left: 50%;<br />
width: 768px; /* table width */<br />
height: 476px; /* table height */<br />
visibility: visible<br />
}<br />
#table_main<br />
{ <br />
font-family:comic sans ms;<br />
font-size:48px;color:#ff0000;<br />
text-align:center;<br />
width: 768px;<br />
height: 476px;<br />
border-style:ridge;<br />
border-width:10px;<br />
border-color:#999999;<br />
padding:1px;<br />
}<br />
//--><br />
</style><br />
</head><br />
<body><br />
<div id="horizon"><br />
<div id="content"><br />
<table id="table_main"><tr><td>This table is now positioned<br />DEAD CENTER</td></tr></table><br />
</div><br />
</div><br />
</body><br />
</html><br />
c:D:Dthead<!--content-->Wo!<br />
<br />
Thanks for the reply, YET I must've worded my question wrong. (Though I'll definitely keep this code for later use) <br />
<br />
Just need to know how to center the table horizontally.<br />
<br />
Gandalf<br />
:D<!--content-->Hi there Thee Gandalf,<br />
<br />
If you only want to center the table horizontally...<br />
then adjust the top in #content to position it vertically<br />
to wherever you want it :cool:<br />
<br />
c:cool::cool:thead<!--content-->if the table is 768 pixels wide how can it center in 800x600 resolutions? not much to center by if it is that wide. just make left equal to auto.<!--content-->This is what I was looking for: <br />
[ margin-left: auto; margin-right: auto; ].<br />
<br />
So now the css code reads as:<br />
<br />
<br />
.table-main<br />
{<br />
text-align: center;<br />
margin-left: auto;<br />
margin-right: auto;<br />
width: 768px;<br />
border-width: 1px;<br />
border-style: solid;<br />
color: #996633;<br />
background-color: transparent;<br />
<br />
<br />
Scoutt, I agree that not much centering can be done with 768px in an 800x600 resolution setting, yet I want to be sure the page content IS center if a higher screen res is used.<br />
<br />
Gandalf<br />
:D<!--content-->
 
Back
Top