Re: DIV Alignment problem 
October 12th, 2008, 06:25 PM
| | |
On 10/12/08 07:41 am, Daniel Kaplan wrote: Quote:
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) | 
October 12th, 2008, 09:15 PM
| | | | re: Re: DIV Alignment problem
"Jim Moe" <jmm-list.AXSPAMGN@sohnen-moe.comwrote in message
news:5OidndAC-YJprG_VnZ2dnUVZ_tTinZ2d@giganews.com... Quote:
On 10/12/08 07:41 am, Daniel Kaplan wrote: Quote:
>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? | 
October 12th, 2008, 09:45 PM
| | | | re: Re: DIV Alignment problem
On 2008-10-12, Daniel Kaplan <NoSPam@NoSpam.comwrote: Quote:
"Jim Moe" <jmm-list.AXSPAMGN@sohnen-moe.comwrote in message
news:5OidndAC-YJprG_VnZ2dnUVZ_tTinZ2d@giganews.com... Quote:
>On 10/12/08 07:41 am, Daniel Kaplan wrote: Quote:
>>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. | 
October 13th, 2008, 01:35 PM
| | | | re: Re: DIV Alignment problem
"Ben C" <spamspam@spam.eggswrote in message
news:slrngf4ntq.6h8.spamspam@bowser.marioworld... Quote:
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...eventually 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.,,, | 
October 13th, 2008, 03:45 PM
| | | | re: Re: DIV Alignment problem
On 2008-10-13, Daniel Kaplan <NoSPam@NoSpam.comwrote: Quote:
>
"Ben C" <spamspam@spam.eggswrote in message
news:slrngf4ntq.6h8.spamspam@bowser.marioworld... Quote:
>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...eventually 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. | 
October 13th, 2008, 10:05 PM
| | | | re: Re: DIV Alignment problem
Ben C wrote: Quote:
>
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 | 
October 13th, 2008, 10:55 PM
| | | | re: Re: DIV Alignment problem
On 2008-10-13, Bergamot <bergamot@visi.comwrote: Quote:
>
Ben C wrote: Quote:
>>
>Use tables for:
>>
>3. equal-height "columns"
| >
I wouldn't make such a blanket statement.
| It wasn't a statement but a suggestion. Quote: |
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. | 
October 13th, 2008, 11:15 PM
| | | | re: Re: DIV Alignment problem
Ben C wrote: Quote: |
Tables are a useful part of CSS
| Tables are not part of CSS. They are part of HTML. | 
October 14th, 2008, 08:55 AM
| | | | re: Re: DIV Alignment problem
On 2008-10-13, Scott Bryce <sbryce@scottbryce.comwrote: Quote:
Ben C wrote: Quote: |
>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. | 
October 14th, 2008, 10:05 AM
| | | | re: Re: DIV Alignment problem
In article <slrngf8jqs.47e.spamspam@bowser.marioworld>,
Ben C <spamspam@spam.eggswrote: Quote:
On 2008-10-13, Scott Bryce <sbryce@scottbryce.comwrote: Quote:
Ben C wrote: Quote: |
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 | 
October 14th, 2008, 03:55 PM
| | | | re: Re: DIV Alignment problem
Ben C wrote: Quote:
On 2008-10-13, Scott Bryce <sbryce@scottbryce.comwrote: Quote:
>Ben C wrote: Quote: |
>>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. | 
October 14th, 2008, 04:15 PM
| | | | re: Re: DIV Alignment problem
On 2008-10-14, Scott Bryce <sbryce@scottbryce.comwrote: Quote:
Ben C wrote: Quote:
>On 2008-10-13, Scott Bryce <sbryce@scottbryce.comwrote: Quote:
>>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. | 
October 14th, 2008, 05:35 PM
| | | | re: Re: DIV Alignment problem
Ben C wrote: Quote:
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. | 
October 14th, 2008, 10:15 PM
| | | | re: Re: DIV Alignment problem
Ben C wrote: Quote:
>
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 | 
October 14th, 2008, 10:45 PM
| | | | re: Re: DIV Alignment problem
On 2008-10-14, Bergamot <bergamot@visi.comwrote: Quote:
>
Ben C wrote: Quote:
>>
>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. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,689 network members.
|