Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > CSS
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

CSS CSS styling code help for your website, CSS is like art and what makes your website look professional.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 1:15 PM   #1
James Luff
 
James Luff's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Vertical centering

Hi,

I found a site that shows how to centre an object vertically on a page
using a table because CSS doesn't support this feature for some reason.

It seemed simple enough to just wrap everything in a table and then
vertical-align : middle everything. It shows it working on the tutorial
page, but having tried the same thing it fails and I don't understand
why. Would someone be kind enough take a look for me and see if they can
discover what I've done wrong?

The tutorial is here:

http://www.quirksmode.org/css/centering.html

and the site I tried to use this technique on is here:

http://www.phillowen.com

The relevant code is here:

style.css
---------

table {
width: 100%;
height: 100%;
}

td {
vertical-align: middle;
text-align: center;
}

#main {
position: relative;
background-image: url(bkg.jpg);
background-repeat: repeat-x;
margin: 0 auto;
width: 750px;
height: 500px;
text-align: left;
}

index.htm
----------

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Phil Lowen</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table>
<tr>
<td>
<div id="main">

<!-- HTML code and content in here -->

</div>
</td>
</tr>
</table>
</body>
</html>

--
regards, James Luff Gamertag: Lufferov
remove 'nospam' to e-mail
"There are 10 types of people in the world:
Those that understand binary, and those that don't."
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Advertisements
Old 07-01-2007, 1:16 PM   #2
Jack Forbes
 
Jack Forbes's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Vertical centering

James

I'm not sure what your problem is, your page looked good on both
browsers I use.

Jack


On Mon, 24 Jul 2006 23:30:22 +0100, James Luff
<james.luff@nospamdsl.pipex.com> wrote:

>Hi,
>
>I found a site that shows how to centre an object vertically on a page
>using a table because CSS doesn't support this feature for some reason.
>
>It seemed simple enough to just wrap everything in a table and then
>vertical-align : middle everything. It shows it working on the tutorial
>page, but having tried the same thing it fails and I don't understand
>why. Would someone be kind enough take a look for me and see if they can
>discover what I've done wrong?
>
>The tutorial is here:
>
>http://www.quirksmode.org/css/centering.html
>
>and the site I tried to use this technique on is here:
>
>http://www.phillowen.com
>
>The relevant code is here:
>

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 1:16 PM   #3
James Luff
 
James Luff's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Vertical centering

Jack Forbes wrote:
> James
>
> I'm not sure what your problem is, your page looked good on both
> browsers I use.


Thanks for looking, the problem is the site should be centred
vertically, at the moment it is just centring horizontally using margin
: auto;

The page should look like this (fixed font required):
________________________________________
|Browser |
| |
| |
| __________________ |
| |Site | |
| | | |
| | | |
| | | |
| |__________________| |
| |
| |
| |
|________________________________________|

But it looks like this:
________________________________________
|Browser __________________ |
| |Site | |
| | | |
| | | |
| | | |
| |__________________| |
| |
| |
| |
| |
| |
| |
|________________________________________|

As I understood it, putting the site inside a table and then using
vertical-align : middle; should put it in the centre of the screen. This
doesn't seem to be working for me and I don't understand why when the
tutorial I linked to does work.

--
regards, James Luff Gamertag: Lufferov
remove 'nospam' to e-mail
"There are 10 types of people in the world:
Those that understand binary, and those that don't."
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 1:16 PM   #4
James Luff
 
James Luff's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Vertical centering

James Luff wrote:
> Jack Forbes wrote:
>> James
>>
>> I'm not sure what your problem is, your page looked good on both
>> browsers I use.

>
> Thanks for looking, the problem is the site should be centred
> vertically, at the moment it is just centring horizontally using margin
> : auto;


I've just noticed, it looks okay at 1024 x 768 because the site fits
fairly well to that resolution. If you go higher the problem becomes
more obvious, it isn't something I'm going to lose sleep over but it's
one of those little things that's going to bug me.

--
regards, James Luff Gamertag: Lufferov
remove 'nospam' to e-mail
"There are 10 types of people in the world:
Those that understand binary, and those that don't."
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 1:16 PM   #5
Jack Forbes
 
Jack Forbes's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Vertical centering



I understand what you are wanting, I can't help but wonder if what is
happening is the table settings are centering on the html page, not
the screen.

What if you use the "80%, 70 %" centering/size command or something
like that to Vertically align the table. It works at any screen
setting for me in the horizontal centering.

On Tue, 25 Jul 2006 23:58:39 +0100, James Luff
<james.luff@nospamdsl.pipex.com> wrote:

>Jack Forbes wrote:
>> James
>>
>> I'm not sure what your problem is, your page looked good on both
>> browsers I use.

>
>Thanks for looking, the problem is the site should be centred
>vertically, at the moment it is just centring horizontally using margin
>: auto;
>
>The page should look like this (fixed font required):
> ________________________________________
>|Browser |
>| |
>| |
>| __________________ |
>| |Site | |
>| | | |
>| | | |
>| | | |
>| |__________________| |
>| |
>| |
>| |
>|________________________________________|
>
>But it looks like this:
> ________________________________________
>|Browser __________________ |
>| |Site | |
>| | | |
>| | | |
>| | | |
>| |__________________| |
>| |
>| |
>| |
>| |
>| |
>| |
>|________________________________________|
>
>As I understood it, putting the site inside a table and then using
>vertical-align : middle; should put it in the centre of the screen. This
>doesn't seem to be working for me and I don't understand why when the
>tutorial I linked to does work.

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 1:16 PM   #6
Jamie Allison
 
Jamie Allison's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Vertical centering


"James Luff" <james.luff@nospamdsl.pipex.com> wrote in message
newstednbFwjK2TPlvZRVnygg@pipex.net...
> James Luff wrote:
>> Jack Forbes wrote:
>>> James
>>>
>>> I'm not sure what your problem is, your page looked good on both
>>> browsers I use.

>>
>> Thanks for looking, the problem is the site should be centred vertically,
>> at the moment it is just centring horizontally using margin : auto;


Your problem is that your content is centered and mid in the table but the
table is not the full height of the screen. Maybe doing a <table height =
"100%"> would help. Not sure if this is valid HTML though so give it a try.

>
> I've just noticed, it looks okay at 1024 x 768 because the site fits
> fairly well to that resolution. If you go higher the problem becomes more
> obvious, it isn't something I'm going to lose sleep over but it's one of
> those little things that's going to bug me.
>
> --
> regards, James Luff Gamertag: Lufferov
> remove 'nospam' to e-mail
> "There are 10 types of people in the world:
> Those that understand binary, and those that don't."



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 1:16 PM   #7
James Luff
 
James Luff's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Vertical centering

Jamie Allison wrote:
>>>> I'm not sure what your problem is, your page looked good on both
>>>> browsers I use.
>>> Thanks for looking, the problem is the site should be centred vertically,
>>> at the moment it is just centring horizontally using margin : auto;

>
> Your problem is that your content is centered and mid in the table but the
> table is not the full height of the screen. Maybe doing a <table height =
> "100%"> would help. Not sure if this is valid HTML though so give it a try.


But that's what this section of code in the CSS file does:

table {
width: 100%;
height: 100%;
}

isn't it? That's how I understood it anyway.

--
regards, James Luff Gamertag: Lufferov
remove 'nospam' to e-mail
"There are 10 types of people in the world:
Those that understand binary, and those that don't."
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 1:16 PM   #8
Jack Forbes
 
Jack Forbes's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Vertical centering

On Fri, 28 Jul 2006 00:34:25 +0100, James Luff
<james.luff@nospamdsl.pipex.com> wrote:

>Jamie Allison wrote:
>>>>> I'm not sure what your problem is, your page looked good on both
>>>>> browsers I use.
>>>> Thanks for looking, the problem is the site should be centred vertically,
>>>> at the moment it is just centring horizontally using margin : auto;

>>
>> Your problem is that your content is centered and mid in the table but the
>> table is not the full height of the screen. Maybe doing a <table height =
>> "100%"> would help. Not sure if this is valid HTML though so give it a try.

>
>But that's what this section of code in the CSS file does:
>
>table {
> width: 100%;
> height: 100%;
>}
>
>isn't it? That's how I understood it anyway.


The problem I see here is you are using the percentage for centering
ok, but it's for centering "within" the table. The table itself is
still centering within the html page, not the display. At least
that's my feeling. Sorry, I don't know how to fix it.

Jack
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 1:16 PM   #9
Jamie Allison
 
Jamie Allison's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Vertical centering


"James Luff" <james.luff@nospamdsl.pipex.com> wrote in message
news:-5CdnfVVMLgc0FTZRVny2w@pipex.net...
> Jamie Allison wrote:
>>>>> I'm not sure what your problem is, your page looked good on both
>>>>> browsers I use.
>>>> Thanks for looking, the problem is the site should be centred
>>>> vertically, at the moment it is just centring horizontally using margin
>>>> : auto;

>>
>> Your problem is that your content is centered and mid in the table but
>> the table is not the full height of the screen. Maybe doing a <table
>> height = "100%"> would help. Not sure if this is valid HTML though so
>> give it a try.

>
> But that's what this section of code in the CSS file does:
>
> table {
> width: 100%;
> height: 100%;
> }


As i thought the height 100% does not make the table 100% the height of the
screen but 100% height of the HTML document. There is nothing else apart
form what is in the table so the table shrinks to fit its contents.

One way would be to possibly set the height in pixels suck as 768 but then
this will only work for certain screen resolutions.

Why are you wanting it centered on the screen? Maybe you could acheive a
similar thing by doing a top margin of x amount?

>
> isn't it? That's how I understood it anyway.
>
> --
> regards, James Luff Gamertag: Lufferov
> remove 'nospam' to e-mail
> "There are 10 types of people in the world:
> Those that understand binary, and those that don't."



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 1:16 PM   #10
James Luff
 
James Luff's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Vertical centering

Jamie Allison wrote:
> As i thought the height 100% does not make the table 100% the height of the
> screen but 100% height of the HTML document. There is nothing else apart
> form what is in the table so the table shrinks to fit its contents.


I understand this, but how does the tutorial I linked to work?

http://www.quirksmode.org/css/centering.html

That has the content centred on the page. Why does his version work and
not mine?

> One way would be to possibly set the height in pixels suck as 768 but then
> this will only work for certain screen resolutions.


Indeed, but as you say, this only work for a certain screen resolution.

> Why are you wanting it centred on the screen? Maybe you could achieve a
> similar thing by doing a top margin of x amount?


Why? It is mainly just a design aesthetic. The idea of using a top
margin of x gives the same problem, what value of x? The value will
always be different depending on screen resolution.

I appreciate your efforts in trying to help me. Any chance you could
investigate the working example above and see if you can spot how it works?

--
regards, James Luff Gamertag: Lufferov
remove 'nospam' to e-mail
"There are 10 types of people in the world:
Those that understand binary, and those that don't."
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to include multiple frames in frameset without predefined dimensions/vertical scrollbar Don Schneider HTML 0 07-01-2007 12:45 PM


Featured Websites




All times are GMT +1. The time now is 1:24 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98