Re: DIV Alignment problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Moe

    Re: DIV Alignment problem

    On 10/12/08 07:41 am, Daniel Kaplan wrote:
    Am making a picture class/container and running into a small problem. I
    can't seem to align the image and/or text in the frame. [...]
    >
    Align the text and image with what?
    The markup (which is invalid) you provided told me very little,
    especially since there was no text in the example. An URL to a test case
    would be far more helpful.

    --
    jmm (hyphen) list (at) sohnen-moe (dot) com
    (Remove .AXSPAMGN for email)
  • Daniel Kaplan

    #2
    Re: DIV Alignment problem

    "Jim Moe" <jmm-list.AXSPAMGN@s ohnen-moe.comwrote in message
    news:5OidndAC-YJprG_VnZ2dnUVZ _tTinZ2d@gigane ws.com...
    On 10/12/08 07:41 am, Daniel Kaplan wrote:
    >Am making a picture class/container and running into a small problem. I
    >can't seem to align the image and/or text in the frame. [...]
    >>
    Align the text and image with what?
    To the container. I simply would like to be able to put the image in the
    container however I like. Maybe at the top, maybe centered, etc. I know I
    can position the image in the container in an absolute fashion, so for
    individual unique images I can set them (and the container borders) wherever
    I wish .

    Perhaps my question should have been... Are there "relative" alignment
    properties so I can place an image in a container easily and with many
    varieties?


    Comment

    • Ben C

      #3
      Re: DIV Alignment problem

      On 2008-10-12, Daniel Kaplan <NoSPam@NoSpam. comwrote:
      "Jim Moe" <jmm-list.AXSPAMGN@s ohnen-moe.comwrote in message
      news:5OidndAC-YJprG_VnZ2dnUVZ _tTinZ2d@gigane ws.com...
      >On 10/12/08 07:41 am, Daniel Kaplan wrote:
      >>Am making a picture class/container and running into a small problem. I
      >>can't seem to align the image and/or text in the frame. [...]
      >>>
      > Align the text and image with what?
      >
      To the container. I simply would like to be able to put the image in the
      container however I like. Maybe at the top, maybe centered, etc. I know I
      can position the image in the container in an absolute fashion, so for
      individual unique images I can set them (and the container borders) wherever
      I wish .
      >
      Perhaps my question should have been... Are there "relative" alignment
      properties so I can place an image in a container easily and with many
      varieties?
      Yes, but they might not be the varieties you want...

      Vertical-align on inline elements is very difficult to understand, does
      a lot of weird things, and not very many helpful things. It's not even a
      very good way to do <suband <supbecause of the way that vertical
      alignment affects line box height.

      If you want a box with contents at the top, in the middle, or at the
      bottom, you can make the box a table-cell and then use vertical-align on
      the table-cell (not on the things inside it). That works in a fairly
      intuitive way-- aligns the contents to the top, middle or bottom of the
      box.

      Comment

      • Daniel Kaplan

        #4
        Re: DIV Alignment problem


        "Ben C" <spamspam@spam. eggswrote in message
        news:slrngf4ntq .6h8.spamspam@b owser.marioworl d...
        Vertical-align on inline elements is very difficult to understand, does
        a lot of weird things, and not very many helpful things. It's not even a
        very good way to do <suband <supbecause of the way that vertical
        alignment affects line box height.
        >
        If you want a box with contents at the top, in the middle, or at the
        bottom, you can make the box a table-cell and then use vertical-align on
        the table-cell (not on the things inside it). That works in a fairly
        intuitive way-- aligns the contents to the top, middle or bottom of the
        box.

        Thanks for the help...eventual ly I got close enough to what I wanted. Of
        course I wanted horizontal centering too. The closest I got was placing
        three containers in one centered container. Although they were flush left
        to it...they wouldn't center within it.

        Am guessing there times when you should use tables?

        Thanks again.,,,


        Comment

        • Ben C

          #5
          Re: DIV Alignment problem

          On 2008-10-13, Daniel Kaplan <NoSPam@NoSpam. comwrote:
          >
          "Ben C" <spamspam@spam. eggswrote in message
          news:slrngf4ntq .6h8.spamspam@b owser.marioworl d...
          >Vertical-align on inline elements is very difficult to understand, does
          >a lot of weird things, and not very many helpful things. It's not even a
          >very good way to do <suband <supbecause of the way that vertical
          >alignment affects line box height.
          >>
          >If you want a box with contents at the top, in the middle, or at the
          >bottom, you can make the box a table-cell and then use vertical-align on
          >the table-cell (not on the things inside it). That works in a fairly
          >intuitive way-- aligns the contents to the top, middle or bottom of the
          >box.
          >
          >
          Thanks for the help...eventual ly I got close enough to what I wanted. Of
          course I wanted horizontal centering too. The closest I got was placing
          three containers in one centered container. Although they were flush left
          to it...they wouldn't center within it.
          >
          Am guessing there times when you should use tables?
          Yes. Use tables for:

          1. tables
          2. vertical centering of auto height blocks
          3. equal-height "columns"
          4. centered shrink-to-fit blocks

          and probably some other things.

          You should use display: table-cell etc. instead of <TABLEif you just
          want the layout effects of tables for data that isn't actually a table.
          It won't work in IE but I can't cure a rainy day.

          Plan B is compromise and stop wanting to centre everything, which it
          sounds like you've done.

          Comment

          • Bergamot

            #6
            Re: DIV Alignment problem


            Ben C wrote:
            >
            Use tables for:
            >
            3. equal-height "columns"
            I wouldn't make such a blanket statement. There are multiple ways to
            accomplish this without tables.

            --
            Berg

            Comment

            • Ben C

              #7
              Re: DIV Alignment problem

              On 2008-10-13, Bergamot <bergamot@visi. comwrote:
              >
              Ben C wrote:
              >>
              >Use tables for:
              >>
              >3. equal-height "columns"
              >
              I wouldn't make such a blanket statement.
              It wasn't a statement but a suggestion.
              There are multiple ways to accomplish this without tables.
              Yes and though they are ingenious I don't much like them.

              There are lots of ways to do anything-- you can do vertical centering of
              blocks without tables too (big line-heights and inline-blocks).

              Tables are a useful part of CSS and the obvious and intuitive way to do
              equal height columns.

              Comment

              • Scott Bryce

                #8
                Re: DIV Alignment problem

                Ben C wrote:
                Tables are a useful part of CSS
                Tables are not part of CSS. They are part of HTML.

                Comment

                • Ben C

                  #9
                  Re: DIV Alignment problem

                  On 2008-10-13, Scott Bryce <sbryce@scottbr yce.comwrote:
                  Ben C wrote:
                  >Tables are a useful part of CSS
                  >
                  Tables are not part of CSS. They are part of HTML.
                  They're part of CSS too. See http://www.w3.org/TR/CSS21/tables.html.

                  And there's no shame whatsoever in using CSS tables for layout.

                  Comment

                  • dorayme

                    #10
                    Re: DIV Alignment problem

                    In article <slrngf8jqs.47e .spamspam@bowse r.marioworld>,
                    Ben C <spamspam@spam. eggswrote:
                    On 2008-10-13, Scott Bryce <sbryce@scottbr yce.comwrote:
                    Ben C wrote:
                    Tables are a useful part of CSS
                    Tables are not part of CSS. They are part of HTML.
                    >
                    They're part of CSS too. See http://www.w3.org/TR/CSS21/tables.html.
                    >
                    And there's no shame whatsoever in using CSS tables for layout.
                    And when the browsers that do not support these are just a memory, we
                    can feel relieved that there will no longer be a need for people to mark
                    up with HTML tables "meaninglessly" . Until then, perhaps a little
                    tolerance is required.

                    --
                    dorayme

                    Comment

                    • Scott Bryce

                      #11
                      Re: DIV Alignment problem

                      Ben C wrote:
                      On 2008-10-13, Scott Bryce <sbryce@scottbr yce.comwrote:
                      >Ben C wrote:
                      >>Tables are a useful part of CSS
                      >Tables are not part of CSS. They are part of HTML.
                      >
                      They're part of CSS too. See http://www.w3.org/TR/CSS21/tables.html.
                      >
                      And there's no shame whatsoever in using CSS tables for layout.
                      The URL you gives shows how to apply CSS to HTML tables, not how they
                      are created using CSS.

                      Comment

                      • Ben C

                        #12
                        Re: DIV Alignment problem

                        On 2008-10-14, Scott Bryce <sbryce@scottbr yce.comwrote:
                        Ben C wrote:
                        >On 2008-10-13, Scott Bryce <sbryce@scottbr yce.comwrote:
                        >>Ben C wrote:
                        >>>Tables are a useful part of CSS
                        >>Tables are not part of CSS. They are part of HTML.
                        >>
                        >They're part of CSS too. See http://www.w3.org/TR/CSS21/tables.html.
                        >>
                        >And there's no shame whatsoever in using CSS tables for layout.
                        >
                        The URL you gives shows how to apply CSS to HTML tables, not how they
                        are created using CSS.
                        You can apply that CSS to anything you want. Typically a UA's default
                        stylesheet contains rules like this:

                        table { display: table }
                        tr { display: table-row }
                        td { display: table-cell }

                        which is how it gets applied to HTML. But you can just as well use:

                        div { display: table-row }
                        span { display: table-cell }

                        etc. if you want.

                        Comment

                        • Scott Bryce

                          #13
                          Re: DIV Alignment problem

                          Ben C wrote:
                          You can apply that CSS to anything you want. Typically a UA's default
                          stylesheet contains rules like this:
                          Well, yes, but my point is that a table is HTML, you apply CSS to the
                          table. That does not make then CSS tables. That makes them HTML tables
                          with styles applied to them using CSS.

                          I think at this point we are arguing semantics.

                          Comment

                          • Bergamot

                            #14
                            Re: DIV Alignment problem


                            Ben C wrote:
                            >
                            You can apply that CSS to anything you want. Typically a UA's default
                            stylesheet contains rules like this:
                            >
                            table { display: table }
                            tr { display: table-row }
                            td { display: table-cell }
                            Except for IE, of course, which doesn't support CSS tables at all. Most
                            web authors aren't willing to let the IE chips fall where they may and I
                            can't say I blame them. That means CSS tables are not really a viable
                            solution, at least not for commercial sites.

                            --
                            Berg

                            Comment

                            • Ben C

                              #15
                              Re: DIV Alignment problem

                              On 2008-10-14, Bergamot <bergamot@visi. comwrote:
                              >
                              Ben C wrote:
                              >>
                              >You can apply that CSS to anything you want. Typically a UA's default
                              >stylesheet contains rules like this:
                              >>
                              > table { display: table }
                              > tr { display: table-row }
                              > td { display: table-cell }
                              >
                              Except for IE, of course, which doesn't support CSS tables at all. Most
                              web authors aren't willing to let the IE chips fall where they may and I
                              can't say I blame them. That means CSS tables are not really a viable
                              solution, at least not for commercial sites.
                              Indeed, which is why tolerance is recommended.

                              IE8 may support display: table-cell since they claim it passes Acid2,
                              and you need display: table-cell for Acid2.

                              Comment

                              Working...