centering question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex K

    centering question

    Does anyone know how to make a div take the width of what it contains?
    NOT the width of what contains it. This is usefull when we don't know
    the size of the content in advance. Thank you so much.

    Alex
  • Ben C

    #2
    Re: centering question

    On 2008-02-07, Alex K <alex.ksikes@gm ail.comwrote:
    Does anyone know how to make a div take the width of what it contains?
    NOT the width of what contains it. This is usefull when we don't know
    the size of the content in advance. Thank you so much.
    Make it float: left (or right), display: table-cell, display: table, or
    display: inline-block.

    Of those only the first is reliable cross-browser.

    Judging by the Subject line your next question is going to be how do I
    centre this shrink-to-fit container. Unfortunately if you chose float
    you can't.

    If you need a centered shrink-to-fit block that also works in IE, the
    only option is HTML tables.

    Comment

    • dorayme

      #3
      Re: centering question

      In article <slrnfqmn82.kg8 .spamspam@bowse r.marioworld>,
      Ben C <spamspam@spam. eggswrote:
      On 2008-02-07, Alex K <alex.ksikes@gm ail.comwrote:
      Does anyone know how to make a div take the width of what it contains?
      NOT the width of what contains it. This is usefull when we don't know
      the size of the content in advance. Thank you so much.
      >
      Make it float: left (or right), display: table-cell, display: table, or
      display: inline-block.
      >
      Of those only the first is reliable cross-browser.
      >
      Judging by the Subject line your next question is going to be how do I
      centre this shrink-to-fit container. Unfortunately if you chose float
      you can't.
      >
      If you need a centered shrink-to-fit block that also works in IE, the
      only option is HTML tables.
      Perhaps OP will benefit from:

      <http://netweaver.com.au/alt/shrinkTo...teringShrinkTo
      Fit.html>

      --
      dorayme

      Comment

      • BootNic

        #4
        Re: centering question

        dorayme <doraymeRidThis @optusnet.com.a uwrote in news:doraymeRid This-
        978BE2.08240508 022008@news-vip.optusnet.co m.au:

        [snip]
        >
        Perhaps OP will benefit from:
        >
        <http://netweaver.com.au/alt/shrinkTo...teringShrinkTo
        Fit.html>
        Oh is see a mistake. Silly me, what was I thinking when I used inline-box
        for IE. It should be inline-block, but I suppose that is the reason I added
        zoom:1; to the rule all in an effort to trigger hasLayout.

        Now that is done display:inline-box; should be display:inline-block; and
        since I don't recall if IE less then 6 needs zoom:1; or not I would leave
        that is as well since it's in a conditional comment.

        --
        BootNic Friday February 8, 2008 11:40 AM
        Behind every successful woman...is a basket of dirty laundry.
        *Sally Poe*

        Comment

        • dorayme

          #5
          Re: centering question

          In article <Xns9A3E76D7596 E2BootNic@bootn ic.motzarella.o rg>,
          BootNic <bootnic.bounce @gmail.comwrote :
          dorayme <doraymeRidThis @optusnet.com.a uwrote in news:doraymeRid This-
          978BE2.08240508 022008@news-vip.optusnet.co m.au:
          >
          [snip]

          Perhaps OP will benefit from:

          <http://netweaver.com.au/alt/shrinkTo...teringShrinkTo
          Fit.html>
          >
          Oh is see a mistake. Silly me, what was I thinking when I used inline-box
          for IE. It should be inline-block, but I suppose that is the reason I added
          zoom:1; to the rule all in an effort to trigger hasLayout.
          >
          Now that is done display:inline-box; should be display:inline-block; and
          since I don't recall if IE less then 6 needs zoom:1; or not I would leave
          that is as well since it's in a conditional comment.
          I should have picked this one up myself. Perhaps at the time I
          regarded anything for IE as like a smelly rat, best left to
          professional pest inspectors. That's you, Bootnic!

          I have taken the opportunity to add a comment in the source for
          the page you refer to. It elevates you in a style that reminds me
          of the way Virgil used to describe his characters, especially
          heroes. See the Aeneid. You are now "the keen-eyed Bootnic".

          <g>

          --
          dorayme

          Comment

          • BootNic

            #6
            Re: centering question

            dorayme <doraymeRidThis @optusnet.com.a uwrote in
            news:doraymeRid This-9B7AEC.07451509 022008@news-vip.optusnet.co m.au:
            In article <Xns9A3E76D7596 E2BootNic@bootn ic.motzarella.o rg>,
            BootNic <bootnic.bounce @gmail.comwrote :
            >
            >dorayme <doraymeRidThis @optusnet.com.a uwrote in
            >news:doraymeRi dThis- 978BE2.08240508 022008@news-vip.optusnet.co m.au:
            >>
            >[snip]
            >
            Perhaps OP will benefit from:
            >
            <http://netweaver.com.au/alt/shrinkTo...teringShrinkTo
            Fit.html>
            >>
            >Oh is see a mistake. Silly me, what was I thinking when I used
            >inline-box for IE. It should be inline-block, but I suppose that is
            >the reason I added zoom:1; to the rule all in an effort to trigger
            >hasLayout.
            >>
            >Now that is done display:inline-box; should be display:inline-block;
            >and since I don't recall if IE less then 6 needs zoom:1; or not I
            >would leave that is as well since it's in a conditional comment.
            >
            I should have picked this one up myself. Perhaps at the time I
            regarded anything for IE as like a smelly rat, best left to
            professional pest inspectors. That's you, Bootnic!
            >
            I have taken the opportunity to add a comment in the source for
            the page you refer to. It elevates you in a style that reminds me
            of the way Virgil used to describe his characters, especially
            heroes. See the Aeneid. You are now "the keen-eyed Bootnic".
            LOL ... Not sure keen-eyed fits, after all it only took 3 months for me
            to spot me own mistake.

            Now me pants are back up tis time to tuck in me shirt. Tis one more
            inline-box that needs to be changed to inline-block. On the URL you
            provided that describes my indiscretion.

            --
            BootNic Friday February 8, 2008 5:46 PM
            The only thing wrong with immortality is that it tends to go on
            forever.
            *Herb Caen*

            Comment

            • dorayme

              #7
              Re: centering question

              In article <Xns9A3EB4DD3F9 CEBootNic@bootn ic.motzarella.o rg>,
              BootNic <bootnic.bounce @gmail.comwrote :
              Tis one more
              inline-box that needs to be changed to inline-block. On the URL you
              provided that describes my indiscretion.
              Right, fixed now... was only looking at the demo mark up
              before... <g>

              --
              dorayme

              Comment

              Working...