Results 1 to 5 of 5

Thread: [RESOLVED] why does this not centre in IE?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Resolved [RESOLVED] why does this not centre in IE?

    I have some code for my header:

    HTML Code:
    <body>
    <div id="header">
    	<div id="logo">
    		<h1><a href="http://www.mysite.co.uk">My site</a></h1>
    	</div>
    	</div>
    <div id="header2">
    	<div id="menu">
    	<ul>
    		<li ><a href="all.php">All</a></li>
    		<li ><a href="womens.php">Women</a></li>
    		<li class="current_page_item"><a href="mens.php">Men</a></li>
    	</ul>
    		<ul>
    	</div>
    </div>
    And the CSS:

    HTML Code:
    #header {
        float: middle;
    	padding: 0px 0 0 0;
    	width: 340px;
    	height: 70px;
    	margin: 0px auto;
    }
    
    #header2 {
    	padding: 20px 0 0 0;
    	width: 620px;
    	height: 70px;
    	margin: 0px auto;
    	text-align: center;
    }
    
    #logo {
    	float: middle;
    	padding: 20px 0px 0 0;
    }
    
    #logo h1 {
    	margin: 0;
    	text-transform: lowercase;
    	letter-spacing: -0px;
    	font-size: 3.6em;
    	font-weight: normal;
    	color: #FFFFFF;
    }
    
    #logo h1 a {
    	padding-right: 20px;
    	background: url(images/img02.gif) no-repeat right top;
    	text-decoration: none;
    	color: #FFFFFF;
    }
    
    #menu {
    	float: middle;
    }
    
    #menu ul {
    	margin: 0;
    	padding: 0;
    	list-style: none;
    }
    
    #menu li {
    	display: block;
    	float: left;
    	height: 82px;
    }

    For some reason the header appears fine on Opera and Firefox - centred. In IE(7) however its just left-aligned.. Any ideas why??? And how do I fix it so its just centred??

    Thanks!

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: why does this not centre in IE?

    To have margin : 0 auto; working you have to make sure you have a Strict DOCTYPE and that it is the first thing in the file (no spaces or extra characters or XML prolog before it).

    On the other news, I've never seen float : middle; before.

  3. #3
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: why does this not centre in IE?

    why don't you try "align: center;"?
    and I would remove the "padding: 0px 0 0 0;" part
    Delete it. They just clutter threads anyway.

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: why does this not centre in IE?

    padding: 0; does what it says, removes padding: in case #header happens to be a real header element, it may have (unwanted) padding assigned so it must be removed separately.

    There is no align: center;, you can find text-align: center; but that should only work for text (but it does work "as wanted" in IE, if you set it to the parent element - just that it also centers the text, so you have to undo that in the child elements).

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Re: why does this not centre in IE?

    Code:
    To have margin : 0 auto; working you have to make sure you have a Strict DOCTYPE and that it is the first thing in the file (no spaces or extra characters or XML prolog before it).
    Thanks - that worked!

Posting Permissions

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



Click Here to Expand Forum to Full Width