www.webdeveloper.com
Results 1 to 3 of 3

Thread: CSS margin-auto when website is long than screen

  1. #1
    Join Date
    Oct 2005
    Posts
    27

    CSS margin-auto when website is long than screen

    Hi, I'm building a new website and I'm having problems centering the website. It work sfine most of the time but when the content goes off the bottom of the screen the website centres differently so some webpages don't align with the others. Please see these pages:

    well aligned: http://demystifydesign.co.uk/christie/about.html

    badly aligned: http://demystifydesign.co.uk/christie/chaplaincy.html

    it also aligns badly if you reduce the size of your browser window so that the content is too long for the window.

    Can anybody help me?

    The CSS for the main container is this:
    Code:
    #container {
    	background-color:#FFFFFF;
    	margin-left:auto;
    	margin-right:auto;
    	margin-top:0px;
    	margin-bottom:0px;
    	position:relative;
    	float:none;
    	padding-top:20px;
    }

  2. #2
    Join Date
    Aug 2006
    Posts
    1,902
    That's because your "long" pages are adding a scroll bar, so the browser has to squeeze your page width down by enough for the scroll bar. A common solution is to force a scroll bar on every page, even if it doesn't need one, via:

    body {overflow:scroll}

    Dave

  3. #3
    Join Date
    Oct 2005
    Posts
    27
    thanks That should be fine for the moment.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles