Topic: Positioning Tables With CSS |
|
|---|---|
| Author | Thread |
|
Bipolar (III) Inmate From: Rochester, Ny |
posted 12-21-2005 23:30
I am trying to position a table so it centers to the middle of the browser all the time. I know it has someting to do with absolute position, sill can't figure out how to do it right though. Sorry if this is a dumb question but I am just starting back at website design and i'm quite rough around the edges. Thanks. |
|
Maniac (V) Inmate From: there...no..there..... |
posted 12-21-2005 23:48
are you talking center as in vertical or horizontal? If it's horizontal then you just set the table to : code: align="center"
code: body{
margin:0px;
padding:0px;
text-align:center;
}
|
|
Paranoid (IV) Inmate From: Florida |
posted 12-22-2005 00:47
please don't use either of the code bits CPrompt posted |
|
Maniac (V) Inmate From: there...no..there..... |
posted 12-22-2005 04:19
quote:
|
|
Bipolar (III) Inmate From: Rochester, Ny |
posted 12-22-2005 04:51
Basically I am trying to take a table about 400x600px and postion it in the middle of the screen. I want it to be in the middle no matter what the screen resolution. |
|
Paranoid (IV) Inmate From: Florida |
posted 12-22-2005 05:46
code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<style type="text/css">
html {
overflow: hidden;
}
body {
margin: 0;
padding: 0;
}
table {
width: 400px;
height: 600px;
position: absolute;
top: 50%;
left: 50%;
margin: -300px 0 0 -200px;
background: #ddeeff;
}
</style>
</head>
<body>
<table>
<tr>
<td></td>
</tr>
</table>
</body>
</html> |
|
Bipolar (III) Inmate From: Rochester, Ny |
posted 12-22-2005 07:12
Thanks alot reisio. One question though. What purpose does this code serve? code: html {
overflow: hidden;
}
code: margin: -300px 0 0 -200px;
|
|
Paranoid (IV) Inmate From: Florida |
posted 12-22-2005 13:47
quote:
quote:
code: margin-top: -300px; margin-right: 0; margin-bottom: 0; margin-left: -200px;
|
|
Bipolar (III) Inmate From: Rochester, Ny |
posted 12-22-2005 18:30
Thanks alot man |