Center a (dynamic width)Division with fixed position

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jezternz
    New Member
    • Jan 2008
    • 145

    Center a (dynamic width)Division with fixed position

    Okay,
    Basicly I want to center a division(horizo ntally), the only catch is the division has position:fixed (or relative if need be). The division's width is dynamic.

    Things that dont work (at least through my testing):
    margin: 0 auto; << Only applies to Static objects
    left: 50%;width (x)px; << Only applies to objects with a constant width

    It works in IE by using margin: 0 auto; (which is very odd to me, but it works). Firefox and Chrome arnt so forgiving.

    Something tells me there is no way I can do this (without javascript at least) in FF/CH.

    Thanks, Josh
  • Death Slaught
    Top Contributor
    • Aug 2007
    • 1137

    #2
    Have you tried placing the division in another division and then giving the parent division the text-align:center style?

    Thanks,
    {\_/}
    (' . ')
    (")[DEATH](")
    (")(")

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      Originally posted by Jezternz
      It works in IE by using margin: 0 auto; (which is very odd to me, but it works).
      as far as I know IE doesn't support position: fixed.

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        'fixed' does not work in IE6 and less, is buggy in IE7 but works in IE8.

        Never, ever look to IE as a reference for how or when things work. It's the worst browser on the planet and 11 years behind all other browsers in modern standards and practices.

        Always, always use a modern browser (not any version of IE) to test your markup first.

        The web developer's mantra: "If it works in IE, but not the other browsers, my markup is wrong."

        Comment

        • Jezternz
          New Member
          • Jan 2008
          • 145

          #5
          Thanks for replies.
          I was under the impression " text-align:center " Only works in IE and not the W3C standard browsers.
          Originally posted by drhowarddrfine
          'fixed' does not work in IE6 and less, is buggy in IE7 but works in IE8.
          Ahhh ok, I have been testing in IE7
          Originally posted by drhowarddrfine
          Always, always use a modern browser (not any version of IE) to test your markup first.
          I always test my markup in FF/CH/IE7
          Originally posted by drhowarddrfine
          The web developer's mantra: "If it works in IE, but not the other browsers, my markup is wrong."
          I apologize, what my question is really is "what would be the correct markup (if possible)" or "what would be an alternative" (since ie6 would not work) :(

          Comment

          • drhowarddrfine
            Recognized Expert Expert
            • Sep 2006
            • 7434

            #6
            Originally posted by Jezternz
            I always test my markup in FF/CH/IE7
            IE7 is not a modern browser. Nor is IE8. Always test in any other browser first. Then check to see if/when IE screws things up. You should never use IE as a reference for how things should work is the point. It can't be trusted to do anything right.

            It might do you better to use Firefox, then Safari, then Chrome or Opera, then IE.

            It will be a lot easier to help you if we had a link or the complete markup to work with.

            Comment

            Working...