How to center a DIV with CSS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • davidbugeja
    New Member
    • Mar 2010
    • 2

    How to center a DIV with CSS

    Page In Question: http://www.saqsi.com/index.php

    I cannot manage to center the contents of DIV page-complete so that all DIVs whole-page and skyscraper look centered on the page. That is appear in the middle.

    What is wrong please? It is driving me crazy.
    Code:
    #complete-page {
    	position: absolute;
    	left: 0px;
    	right: 0px;
    	top: 0px;
    	width: 100%;
    	margin: auto;
    }
    #whole-page {
    	Z-INDEX: 139;
    	float: left;
    	BORDER-RIGHT: #cccccc 1px solid;
    	PADDING-RIGHT: 0px! important;
    	PADDING-LEFT: 0px! important;
    	PADDING-BOTTOM: 0px! important;
    	margin: auto;
    	MARGIN-TOP: 5px;
    	BORDER-LEFT: #cccccc 1px solid;
    	WIDTH: 750px;
    	PADDING-TOP: 0px! important;
    	BORDER-BOTTOM: #cccccc 1px solid;
    	POSITION: relative;
    	BACKGROUND-COLOR: #fff;
    }
    #skyscraper {
    	float:left;
    	padding: 5px;
    	width:120px
    }
  • Niheel
    Recognized Expert Moderator Top Contributor
    • Jul 2005
    • 2432

    #2
    Try this:
    Code:
    #complete-page {
    left:0;
    margin:auto;
    right:0;
    text-align:center;
    top:0;
    width:910px;
    }
    Basically you had 100% width, which we changed to 750(content)+16 0(sky) = 910px and absolute postioning.
    niheel @ bytes

    Comment

    • davidbugeja
      New Member
      • Mar 2010
      • 2

      #3
      Thanks fixed it! Thanks a lot for the code and the explanation. I really appriciate it and my head is less worry free now.

      Thanks to lot to you and this website.

      Comment

      Working...