Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2008
    Posts
    223
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Centered in all browsers except Safari

    I have all elements of my page all wrapped in this div:

    Code:
    #column-wideNEW {
       width: 925px;
       height: 1320px;
       border:1px solid #000000;
       margin: 0 auto;
      }
    It looks good and centered in all browsers, except safari(via iphone) it is flush left.

    So, then I've removed all elements and left just this on the page:

    Code:
    <div id="column-wideNEW">
    </div>
    Removed cache & browser history, rebooted - restarted, and the whole page shows in safari, it just shows the #000000 bordered area still flush left on the page, and shows it centered in IE, Chrome & FF. Any ideas as to why?

    Any help/suggestions will be appreciated.
    Last edited by chrisjchrisj; 11-02-2013 at 11:17 PM.

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,748
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Hello chrisjchrisj,
    To center an element you need three things:
    1. a valid DocType
    2. an element with a width
    3. that elements right/left margins set to auto


    The code you post won't work because your #column-wideNEW is not styled. If you change that divs name to match to column-wide so it matches your CSS, it will center ... assuming the rest of your code is valid.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    Regular Coder
    Join Date
    Feb 2008
    Posts
    223
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Thanks

    Thanks for your reply.

    I mistakenly had the un-matched div name and css name here in this post, (which I've corrected/edited here), but it matches in the actual html and css code of my page.

    You said
    that elements right/left margins set to auto, do you mean like this?:

    Code:
    margin: 0px auto 0px auto;

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,748
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Yes, that works. The short version is like this margin: 0 auto; and works just as well.

    Can you post an example of your code that's not centering properly? What you've given us so far should work so it must be something else. Of course, I don't have an iPhone to view it in and Safari may just render sites differently?
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Posting Permissions

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