centered css site in all screen resolutions

This is a discussion on "centered css site in all screen resolutions" within the Web Page Design section. This forum, and the thread "centered css site in all screen resolutions are both part of the Design Your Website category.



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

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 19th, 2008, 11:16
Junior Member
Join Date: Sep 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
centered css site in all screen resolutions

Hi, i have recently built a site using html and css.
When i view the site on a screen resolution of 1024px and above it looks fine and the site is centered on the screen.

Whoever, when i view the site in 800px by 600px screen res the site moves to the right and you have to scroll over the the right and down to view the page.

I have used absolute positioning for all elements of the site images, navigation etc.

Is there a way to allow my site to be centered in every screen resolution.

I have tried using a container but it didnt work. does my positioning of all the site elements need to be changed in the style sheet to accomodate the container.

Thanks
Forry
Reply With Quote

  #2 (permalink)  
Old Feb 19th, 2008, 11:30
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,004
Blog Entries: 2
Thanks: 5
Thanked 23 Times in 20 Posts
Send a message via Skype™ to Aso
Re: centered css site in all screen resolutions

Is your site wider than 800px? If so, all browsers whose window is smaller than the site in question, will render it to the left with the ability to scroll right.
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Reply With Quote
  #3 (permalink)  
Old Feb 19th, 2008, 11:42
Junior Member
Join Date: Sep 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

No the site is 800px by 600px.
When its viewed in an 800 by 600 screen res it moves the whole site to the right. its not centered

Thanks
Reply With Quote
  #4 (permalink)  
Old Feb 19th, 2008, 11:45
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,004
Blog Entries: 2
Thanks: 5
Thanked 23 Times in 20 Posts
Send a message via Skype™ to Aso
Re: centered css site in all screen resolutions

Is it possible for you to host the site / send a link? Or if not, post your HTML and CSS.
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Reply With Quote
  #5 (permalink)  
Old Feb 19th, 2008, 11:48
Junior Member
Join Date: Sep 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

ye sure the link is http://www.3dgardendesign.co.uk/

I have just tried it in all res below my screen res of 1280 by 1024.

It looks to me like the site is positioned to absolute position i entered in the css code.

It looks like it doesnt move form its position in 1280 on other screen res
Reply With Quote
  #6 (permalink)  
Old Feb 19th, 2008, 11:55
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

Drop the absolute positioning, and use the CSS margin: 0 auto; on your main container.
Reply With Quote
  #7 (permalink)  
Old Feb 19th, 2008, 13:43
Junior Member
Join Date: Sep 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

Hi, i tried that but still doesnt work.

I dont know if i am doing soemthing wrong in the rest of my css to make the container not work properly

This is my style in the css for the container

#container {
background-color: #232222;
padding: 0;
margin:0 auto;
position: relative;
width: 100%;
height:: 100%;
text-align: center;
}

In the html i have palced the div at beginning of the body and closed the div at end of the body
<body>
<div id="container">

Thanks
Reply With Quote
  #8 (permalink)  
Old Feb 19th, 2008, 13:50
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: centered css site in all screen resolutions

Drop the position: relative?
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #9 (permalink)  
Old Feb 19th, 2008, 15:03
Junior Member
Join Date: Sep 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

I tried dropping the position relative. still no joy.
I have been told to add a table and contain everything inside the table.
I dont really want to go down that road of using tables

does anyone have any links on how to design a website that is positioned centered in every screen resolution.

Thanks
Reply With Quote
  #10 (permalink)  
Old Feb 19th, 2008, 15:05
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: centered css site in all screen resolutions

NO TABLES!

Just try dropping the text-align center bit.
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #11 (permalink)  
Old Feb 19th, 2008, 15:19
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

The auto margins method does work. But you need to understand what you're doing. You can't just apply it to any random box and expect it to work.
  • The things you want to centre must be inside the container <div>
  • You must specify a width for the container
  • Your must use a valid doctype
  • If you're using IE, you must be on IE6 or newer (doesn't work in IE5)
Reply With Quote
  #12 (permalink)  
Old Feb 19th, 2008, 15:21
Reputable Member
Join Date: Oct 2007
Location: UK
Posts: 267
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

Do u not have to define the width of a div in pxels for margin: 0 auto; to work?

Try changing width: 100%; to width: 800px;

Also, your css u have 2 ':' ----> height:: 100%;
Reply With Quote
  #13 (permalink)  
Old Feb 19th, 2008, 17:09
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

You can define the width in any unit (but 100% is obviously useless for centring!).
Reply With Quote
  #14 (permalink)  
Old Feb 19th, 2008, 17:45
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: centered css site in all screen resolutions

Yes I was about to say that, if it's width is 100% in essence it is always centered. But you say you have a large margin to the left?
Quote:
when i view the site in 800px by 600px screen res the site moves to the right and you have to scroll over the the right and down to view the page.
Can I see your entire CSS please? Plus the HTML?

Thanks!
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #15 (permalink)  
Old Feb 20th, 2008, 01:31
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: centered css site in all screen resolutions

Don't set your content area a fixed width, make their width in percentage value instead
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #16 (permalink)  
Old Feb 20th, 2008, 07:38
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

Quote:
Originally Posted by Monie View Post
Don't set your content area a fixed width, make their width in percentage value instead
Even better, use ems.
Reply With Quote
  #17 (permalink)  
Old Feb 20th, 2008, 07:52
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: centered css site in all screen resolutions

I usually do use em for my font size, but I never used them to specify any of my div elements
What's the advantage of using them Mike?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #18 (permalink)  
Old Feb 20th, 2008, 08:02
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

Quote:
Originally Posted by Monie View Post
I usually do use em for my font size, but I never used them to specify any of my div elements
What's the advantage of using them Mike?
The advantage of ems is that you can create layouts that fit any font size. So when users resize the font, everything remains in proportion.

This function is also provided by browser zoom features, but they zoom everything. The most common reason to want zoom is for reading text more easily, not for blowing up images. Font resizing provides a more efficient use of space than whole-page zoom (plus it's faster and doesn't look as ugly).

You don't often see these kinds of layouts, but I really like them. Go to my site, the Badminton Bible, and resize the text. Note how the layout adapts.

You can of course use a combination of layout units. I use mostly ems, then px (for image-related layout), and occasionally %.

Last edited by MikeHopley; Feb 20th, 2008 at 08:06.
Reply With Quote
  #19 (permalink)  
Old Feb 20th, 2008, 10:14
welshstew's Avatar
Lead Administrator

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,388
Blog Entries: 13
Thanks: 1
Thanked 16 Times in 14 Posts
Re: centered css site in all screen resolutions

if you aren't used to this type of design and plan on using ems and %'s then this conversion table may be useful for you
__________________
WelshStew
Lead Administrator

tierney rides tboard - uk site | xtreme wales - extreme clothing
If you think I've helped, click the "Thanks"
webforumz - facebook | LinkedIn
Last Blog Entry: Web Standards Curriculum Launched (Jul 8th, 2008)
Reply With Quote
  #20 (permalink)  
Old Feb 20th, 2008, 10:45
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centered css site in all screen resolutions

Quote:
Originally Posted by welshstew View Post
if you aren't used to this type of design and plan on using ems and %'s then this conversion table may be useful for you
Yet another good link from Stew!
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
Need help with different resolutions dcampbell18 Starting Out 5 May 7th, 2008 05:46
Designing Web Sites For All Screen Resolutions shinesmithdas Starting Out 8 Nov 17th, 2007 21:27
Background resolutions? Clarky Website Planning 6 Jul 25th, 2007 21:36
Problem with different resolutions dawg9 Web Page Design 7 Feb 23rd, 2007 03:04


All times are GMT. The time now is 08:36.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs 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 43