Jump to content

Centering table...


Sologuy

Recommended Posts

Hey guysProblem quite simple I suppose, but I can't figure it out. (kinda new at it)Got a page built up by tables and it has a rather small width and height. It looks kinda dull having it in the upper left corner all the time. So I'd like to center it in the middle of the window/body what ever.It's just one table really, so just that one thing that needs alignment.Help? :)

Link to comment
Share on other sites

the <table align="center"> doesn't work in explorer for some reason, but in mozilla... and it shows a horizontal scrollbar on the window when I use it.Which the css margin: 0 auto solved now I figured. Still doesn't work in explorerAnyway, I do use a separate CSS document for the page. I'd like to be able to center it from there without using the html align="center".So far it's the most simple construction of tables

<html><head><link rel="stylesheet" type="text/css" href="toys.css" /><title> Toys </title></head><body><table align="center"> <tr>  <td class="left" />  <td class="right">  <img class="toyman" src="images/toyman.jpg"><br>Toyman creates another toy<br>just thinking about bringing joy<br>Some of them may be crappy<br>but most of them make you happy<br>Made with love and care<br>quality for wear and tear<br>Some for sun, some for rain<br>enough to make you come back again  </td> </tr></table></body></html>

and this is the css

body{margin:0 auto}table{border-collapse: collapse;position: absolute;}td.left{width: 480px;height: 500px;background-image: url(images/snurra.jpg);}td.right{font-family: verdana;font-style: italic;vertical-align: top;text-align: center;vertical-align: middle;font-size: 90%;padding-bottom: 50px;}img.toyman{margin-top:;margin-bottom: 40px;margin-right: 10px;}

I'd like both a vertical and a horizontal align ontop of that =P

Link to comment
Share on other sites

Hey guysProblem quite simple I suppose, but I can't figure it out. (kinda new at it)Got a page built up by tables and it has a rather small width and height. It looks kinda dull having it in the upper left corner all the time. So I'd like to center it in the middle of the window/body what ever.It's just one table really, so just that one thing that needs alignment.Help? :)

<table align="center" valign="middle">
Link to comment
Share on other sites

http://www.jakpsatweb.cz/css/css-vertical-...r-solution.htmlI just came across this article. It is a bit hackish but should work and is very compatible with many browsers.Hope this helps

Thanks, but yeah, hackish =PIt's too much trouble. I'll just put a damn margin on it! hahaCheers for your help anyway guys. Damn that there ain't a good vertical align when the horizontal center works fine.
Link to comment
Share on other sites

It is hard to find solutions to a number of issues. It usually boils down to one thing. Lack of standard complient browsers. If everyone, mostly MS, would jump on board we won't have half the head aches we do!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...