www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > HTML

    HTML Discussion and technical support for building, using and deploying HTML sites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 06-15-2007, 05:51 PM
    blade52x blade52x is offline
    Know Nothing... Yet
     
    Join Date: Dec 2006
    Posts: 68
    Margin:AUTO does not work in IE

    I center a lot of things using css with

    #div {margin:auto; width:xxx;}

    While this works in FF perfectly, IE does not center this div - so how do I get things to center IE as well?
    Reply With Quote
      #2  
    Old 06-15-2007, 06:05 PM
    Mr Initial Man's Avatar
    Mr Initial Man Mr Initial Man is offline
    Registered User
     
    Join Date: Sep 2004
    Location: At the corner of WALK and DONT WALK
    Posts: 1,402
    The best way is to give a parent element to #div, and write something like

    #divparent{text-align:center;}
    #div {margin:auto; width:xxx; text-align:left;} (unless you want the text centered as well.)
    __________________
    Coach Random Comic
    Reply With Quote
      #3  
    Old 06-15-2007, 06:34 PM
    blade52x blade52x is offline
    Know Nothing... Yet
     
    Join Date: Dec 2006
    Posts: 68
    Text alignment is not my problem - but thanks anyway.

    I should have been more detailed. My problem is entire "blocks" of information are not being centered. For example - the biggest block: the website wrapper is not being centered.

    #wrapper {margin:auto; width:1000px; height:100%; margin-top:5px; background-color:white; overflow:auto}

    That's what I have - and all content goes inside of this 1000px wide block (website meant for 1024x768 resolution and higher, I can't stand making ones for less). Anyway, in FF, this entire block is centered, while in IE is appears on the left.

    Last edited by blade52x; 06-15-2007 at 06:41 PM.
    Reply With Quote
      #4  
    Old 06-15-2007, 06:45 PM
    Mr Initial Man's Avatar
    Mr Initial Man Mr Initial Man is offline
    Registered User
     
    Join Date: Sep 2004
    Location: At the corner of WALK and DONT WALK
    Posts: 1,402
    You don't understand, bud. IE doesn't support margin:auto;. text-align:center is a workaround. Try it.
    __________________
    Coach Random Comic
    Reply With Quote
      #5  
    Old 06-15-2007, 07:22 PM
    blade52x blade52x is offline
    Know Nothing... Yet
     
    Join Date: Dec 2006
    Posts: 68
    Ok lol I didn't understand (but now I do), so I tried it and it worked!

    Thank you!
    Reply With Quote
      #6  
    Old 06-15-2007, 07:53 PM
    WebJoel's Avatar
    WebJoel WebJoel is offline
    Super Moderator
     
    Join Date: Dec 2005
    Location: American, living in Toronto, ON. CANADA
    Posts: 6,662
    IE does support "margin:auto;" if there is a WIDTH to the element, and a valid !doctype. In the lack of a valid !doctype, IE is in 'quirks mode' and 'guesses' (worse than usual)...

    Quote:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <meta http-equiv="Content-Script-Type" content="text/javascript" />
    <title></title>
    <style type="text/css">
    * {border:0; padding:0; margin:0;}/* Set everything to "zero" */

    body {min-height:100%; height:101%;
    font:x-small Arial, Verdana, sans-serif;
    voice-family: "\"}\"";voice-family:inherit;
    font-size:small;/*for IE 5.5 */
    } html>body {font-size:small; height:auto;}/* Assist IE6 & <, 100% height */
    font-size: small; voice-family: "\"}\"";
    voice-family: inherit; font-size: medium;} /* Assist IE rendering height, keyword-font sizes, etc. */

    p {font-size: 90%; line-height:1.3em; margin:12px 0 2px 0;}
    h1, h2, h3, h4, h5, h6 {font-family: 'times new roman', arial, verdana, serif; background-color:none;
    font-style:normal; font-variant:normal; font-weight:normal; margin:14px 0 4px 10px;}
    h1{font-size: 1.93em;}
    h2{font-size: 1.72em;}
    h3{font-size: 1.52em;}
    h4{font-size: 1.42em;}
    h5{font-size: 1.32em;}
    h6{font-size: 1.21em;}
    </style>

    <script type="text/javascript"><!--
    // -->
    </script>
    <link rel="shortcut icon" href="favicon.ico"><!-- path to your favicon -->
    </head>
    <body>


    <div style="width:400px; height:400px; padding:15px; border:5px double gray; margin:auto;">
    <h1>First/main header</h1>
    <p>Your text goes here to say whatever you have to say, etc.Your text goes here to say whatever you have to say, etc.Your text goes here to say whatever you have to say, etc.</p>
    </div>


    </body>
    </html>
    This centers the div, while text-align:center; centers the text that is in the container.
    __________________
    Help Save Ana My Portal: I Build WebPages
    Pricing? Read:http://www.webdeveloper.com/forum/pricing_faq.html
    AUP: http://www.jupitermedia.com/corporate/privacy/aup.html
    I test with: Firefox, Mozilla, Opera, Safari-on-XP, Google Chrome, SeaMonkey
    Internet.com freelancers

    Last edited by WebJoel; 06-15-2007 at 07:57 PM.
    Reply With Quote
      #7  
    Old 06-15-2007, 09:29 PM
    Centauri's Avatar
    Centauri Centauri is offline
    Registered User
     
    Join Date: Mar 2006
    Location: Newcastle NSW Australia
    Posts: 4,033
    Quote:
    Originally Posted by Mr Initial Man
    IE doesn't support margin:auto;.
    False information ...............
    Reply With Quote
      #8  
    Old 06-17-2007, 11:09 AM
    WebJoel's Avatar
    WebJoel WebJoel is offline
    Super Moderator
     
    Join Date: Dec 2005
    Location: American, living in Toronto, ON. CANADA
    Posts: 6,662
    [QUOTEFalse information ...............[/quote] I'm a little more charitable here... doesn't support it without a width statement and a valid !doctype. I could see how one might at first run at this might think that IE doesn't support margin:auto;. OP asked 'how to center in IE' but also mentioned 'works in Firefox' and without seeing the whole code, 99% confidence that this is a missing valid !doctype issue.
    __________________
    Help Save Ana My Portal: I Build WebPages
    Pricing? Read:http://www.webdeveloper.com/forum/pricing_faq.html
    AUP: http://www.jupitermedia.com/corporate/privacy/aup.html
    I test with: Firefox, Mozilla, Opera, Safari-on-XP, Google Chrome, SeaMonkey
    Internet.com freelancers
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    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 Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:10 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.