Need help on keeping everything centered but with a min size

This is a discussion on "Need help on keeping everything centered but with a min size" within the Web Page Design section. This forum, and the thread "Need help on keeping everything centered but with a min size 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 Oct 1st, 2007, 05:11
Junior Member
Join Date: Sep 2007
Location: usa
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Need help on keeping everything centered but with a min size

I am having a little trouble with my website. If you pull and adjust the size of this page (the webforumz page) the center section stays a fixed width, is centered on the page and is always a minimum distance away from the edges. How do you do that? What do I need to adjust in my code? My site is www.stevesdealpage.com and it has 5 sections on each page. Here is a copy of the head for the sections of my site
HTML: Select all
<style type="text/css">
<!--
/* title banner box */
#apDiv1 {
    position:absolute;
    left:15px;
    top:15px;
    width:790px;
    height:40px;
    z-index:1;
    background:#ff0000;
}
/* menu bar box */
#apDiv2 {
    position:absolute;
    left:15px;
    top:70px;
    width:105px;
    height:920px;
    z-index:2;
    background:#000000;
}
/* ads box */
#apDiv3 {
    position:absolute;
    left:680px;
    top:70px;
    width:125px;
    height:920px;
    z-index:3;
    background:#000000;
}
/* copyright box */
#apDiv4 {
    position:absolute;
    left:15px;
    top:1005px;
    width:790px;
    height:24px;
    z-index:4;
    background:#ff0000;
}
/* main area */
#apDiv5 {
    position:absolute;
    left:125px;
    top:70px;
    width:545px;
    height:920px;
    z-index:5;
    background:#000000;
}

Last edited by karinne; Oct 1st, 2007 at 12:18. Reason: Please use the vBcode tags when inserting code in your post.
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 Oct 1st, 2007, 06:21
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,404
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: Need help on keeping everything centered but with a min size

You need to create a wrapper/container div that all your content goes in.

Code: Select all
#wrapper {
width: 800px;
margin: 0 auto; 
}
Code: Select all
<div id="wrapper">
..content..
</div>
This will require a bit of re-work with your current CSS, but good luck!

jack
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
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 Oct 1st, 2007, 08:48
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Need help on keeping everything centered but with a min size

Quote:
Originally Posted by jackfranklin View Post
You need to create a wrapper/container div that all your content goes in.

Code: Select all
#wrapper {
width: 800px;
margin: 0 auto; 
}
Code: Select all
<div id="wrapper">
..content..
</div>
This will require a bit of re-work with your current CSS, but good luck!

jack
Hai jackfranklin,

I don't think that that will solve the problem.
He is using a lot of {position: absolute} in all of the element. I tried to do the same solution but nothing happen to the content position.

ziplock122949, whats up with the {position: absolute} things?
Can you not use that to position your div elements? The css code that jackfranklin gave you can only be used if you throw away the {position: absolute} set it to default value and use the wrapper to position your site in the center of the screen.

The key properties in centering your site is the (margin: 0 auto}
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 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
  #4  
Old Oct 1st, 2007, 15:31
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,404
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: Need help on keeping everything centered but with a min size

Quote:
Originally Posted by monie View Post
Hai jackfranklin,

I don't think that that will solve the problem.
He is using a lot of {position: absolute} in all of the element. I tried to do the same solution but nothing happen to the content position.
Yes, that is what I mean't when I said 'this requires a bit of re-work with your code'. You need to get rid of the position: absolute for this to work.
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
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 Oct 2nd, 2007, 01:47
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Need help on keeping everything centered but with a min size

yeah, misunderstood!

It's up to ziplock to do the trick...
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

Last edited by Monie; Oct 2nd, 2007 at 01:50.
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 Oct 2nd, 2007, 08:42
Junior Member
Join Date: Sep 2007
Location: usa
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help on keeping everything centered but with a min size

ok, got me half way to my goal. I deleted the position lines, added the wrapper header code and started the wrapper and ended it just inside the <body> and </body>. The page stays centered but all of the div sections from before are vertically one right after another.
i just started editing one of my temp files so if something bad happened it wouldnt matter too much here is the link
http://www.stevesdealpage.com/storetemp.php
I tried deleting the left and top also but it didnt work.

thanks for the help too. I only know a little html but making programs for engineering classes helps me figure out what the heck everything is trying to do. (I have no clue what the programming languages are that we learned, it was using matlab mostly.) Having a idea of what is going on is helping since the website uses some open code here and there while allowing me to do some deeper editing than most beginners can do.

Last edited by ziplock122949; Oct 2nd, 2007 at 08:46.
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 Oct 2nd, 2007, 08:48
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Need help on keeping everything centered but with a min size

Your link did not work!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 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
  #8  
Old Oct 2nd, 2007, 12:05
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,404
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: Need help on keeping everything centered but with a min size

On my screen the site is in the center so well done

Jack
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
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 Oct 2nd, 2007, 15:30
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Need help on keeping everything centered but with a min size

Quote:
Originally Posted by monie View Post
Your link did not work!
Did for me
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
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 Oct 3rd, 2007, 05:53
Junior Member
Join Date: Sep 2007
Location: usa
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help on keeping everything centered but with a min size

Anyone know how to finish this up? Having a little difficulty moving the sections to where I want them.
the body looks like this
PHP: Select all

<body>
<
div id="wrapper">
<
div class="style1" id="apDiv1"> ...
...
all the content and other sections...
...
</
div>
</
div>
</
body
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 Oct 3rd, 2007, 07:31
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Need help on keeping everything centered but with a min size

Quote:
Originally Posted by monie View Post
Your link did not work!
Ok, it work now..

Quote:
Originally Posted by ziplock122949 View Post
Anyone know how to finish this up? Having a little difficulty moving the sections to where I want them.
Where do you want to move them?
Vertically? Horizontally...?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

Last edited by Monie; Oct 3rd, 2007 at 08:01.
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 Oct 5th, 2007, 03:34
Junior Member
Join Date: Sep 2007
Location: usa
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help on keeping everything centered but with a min size

so it is in the same layout as my other pages right now (www.stevesdealpage.com) Im trying to get the current look inside the wrapper but its not working (www.stevesdealpage.com/storetemp.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
  #13  
Old Oct 5th, 2007, 08:59
Emzi's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Manchester
Age: 25
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help on keeping everything centered but with a min size

Try applying 'float:left;' to the DIV's that are appearing wrong.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Oct 5th, 2007, 09:10
welshstew's Avatar
Site Admin

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,707
Blog Entries: 14
Thanks: 3
Thanked 33 Times in 31 Posts
Re: Need help on keeping everything centered but with a min size

Ziplock, why not filp this baby around, and change the main site to be like the store (i.e. centered) I think it looks a lot better when it's in the middle of the screen (personal opinion)
__________________
WelshStew Site Admin
If you think I've helped, click the "Thanks"
tierney rides tboard - uk site | xtreme wales - extreme clothing
WebForumz - facebook | LinkedIn
Last Blog Entry: Phorm approved for UK rollout (Sep 17th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Oct 7th, 2007, 18:49
Junior Member
Join Date: Sep 2007
Location: usa
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help on keeping everything centered but with a min size

Quote:
Originally Posted by welshstew View Post
Ziplock, why not filp this baby around, and change the main site to be like the store (i.e. centered) I think it looks a lot better when it's in the middle of the screen (personal opinion)
Thats what I am trying to do but its not working so well. I want the current layout to be the same but just inside the wrapper which is centered. As you can see by the test page it doesnt keep the layout it just puts one div section after another vertically so everything is out of place.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Oct 7th, 2007, 20:13
Highly Reputable Member
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help on keeping everything centered but with a min size

Can you post your css again?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!