[SOLVED] page centering issues

This is a discussion on "[SOLVED] page centering issues" within the Web Page Design section. This forum, and the thread "[SOLVED] page centering issues are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Nov 29th, 2007, 09:15
Junior Member
Join Date: Dec 2005
Location: Netherlands
Age: 46
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] page centering issues

Can anyone explain the following:

On my indexpage I run a slideshow using javascript.

I have centered my page using:
Code: Select all
<body LEFTMARGIN=0 TOPMARGIN=0 onLoad="runSlideShow()">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
.....rest of code
so far so good, but when I switch to another page without javascript also centering using the code:

Code: Select all
<body LEFTMARGIN=0 TOPMARGIN=0>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
.....rest of code


a shift occurs of 5 pixels to the left, and 8 pixels to the top. I can prevent this by just putting a <script></script> in the header of the other page. But I would like to understand why this happens.

http://www.cosmicwebdesign.nl/akker/index.php
http://www.cosmicwebdesign.nl/akker/kbp1.php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Nov 29th, 2007, 10:07
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: page centering issues

Your code is invalid, with 24 HTML errors. Fix them first, then see whether you still have the problem.

Note also that this is a bad method for centring your site and controlling margins. Use CSS instead.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Nov 29th, 2007, 12:20
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: page centering issues

Use CSS to center you site - How do I center my site horizontally?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Nov 29th, 2007, 16:56
Junior Member
Join Date: Dec 2005
Location: Netherlands
Age: 46
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Re: page centering issues

I will buy a CSS bible, to see whether I can solve the problem. I need to center my page in both directions (not only horizontally). I found out that the (bad) way I'm using, gives me the results I want, except for this strange javascript behaviour.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Nov 29th, 2007, 17:00
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: page centering issues

How to centre horizontally and vertically?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Dec 3rd, 2007, 14:18
Junior Member
Join Date: Dec 2005
Location: Netherlands
Age: 46
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Re: page centering issues

Since I'm not very into CSS (haven't received my bible yet ),
I've come up with this code in the header

Code: Select all
<style type="text/css" media="screen">
<!--
/* commented backslash hack for ie5mac \*/ 
html, body{height:100%;} 
html,body {margin:0;padding:0;}
/* end hack */
#verticaal{
 position:absolute;
 top:50%;
 margin-top:-282px;/* half height*/
 width:100%;
}
#horizontaal {
 position:absolute;
 left:50%;
 margin-left:-400px;/* half width*/
 height:100%;
}
-->
</style>
:

and used

Code: Select all
<div id="verticaal"> 
<div id="horizontaal">
pageitems to center
in my case a table....
</div>
</div>
I hope this is the correct way to center my page in both directions ?
If so, thanks for pointing me in the right direction !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Dec 3rd, 2007, 14:22
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: page centering issues

My god, what hideous code!

All you need is { margin: 0 auto; }.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Dec 4th, 2007, 14:13
Junior Member
Join Date: Dec 2005
Location: Netherlands
Age: 46
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Re: page centering issues

Quote:
Originally Posted by MikeHopley View Post
My god, what hideous code!

All you need is { margin: 0 auto; }.
Just grapped the code from the examples Karinne was pointing me to.....

I ordered my CSS bible, so within no time I will understand more about the mountains and pitfalls of it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Dec 4th, 2007, 14:43
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: page centering issues

My mistake: you're centring vertically as well (what a weird thing to do). {margin: 0 auto } will not suffice.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Dec 4th, 2007, 14:55
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: page centering issues

Moving to CSS forum
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Dec 4th, 2007, 14:55
Junior Member
Join Date: Dec 2005
Location: Netherlands
Age: 46
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Re: page centering issues

I thought you where aiming at
Code: Select all
html, body{height:100%;} 
html,body {margin:0;padding:0;}
because I already found out that what you proposed only sets the starting position to the left uppercorner.

Quote:
Originally Posted by MikeHopley View Post
what a weird thing to do
I love to make centered pages it's a kind of house-style, and they sell very well ! My problems started when I used javascript to make a slide show on one page......

But everything works fine now
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Dec 4th, 2007, 14:58
Marc's Avatar
Staff Manager

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 1,794
Thanks: 0
Thanked 17 Times in 17 Posts
Re: page centering issues

So.. The problem is solved?
__________________
Marc
Staff Manager - Webforumz.com


Want to be a moderator? PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Dec 4th, 2007, 15:06
Junior Member
Join Date: Dec 2005
Location: Netherlands
Age: 46
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Re: page centering issues

Yes it is. CSS did the trick, although I haven't figured out what the real problem was using the (wrong)centering way as earlier discribed. Another good thing is that centering with CSS gives good results in IE7 when the zoom function is used.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

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

BB 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
Centering a Page In CSS britishchampion Web Page Design 5 Jan 3rd, 2008 16:20
[SOLVED] Centering a layer based page for different screen sizes? Mulith Starting Out 11 Oct 31st, 2007 02:40
[SOLVED] Centering an image with CSS without moving anything else on the page. Ed Web Page Design 5 Oct 29th, 2007 11:34
Need Help Centering my index page??? 0413 Starting Out 6 Jun 9th, 2007 06:40
Centering page question bklcomputing Web Page Design 1 May 20th, 2005 18:49


All times are GMT. The time now is 06:09.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

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