By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

Re: DIV Alignment problem

P: n/a
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)
Oct 12 '08 #1
Share this Question
Share on Google+
14 Replies


P: n/a
"Jim Moe" <jm***************@sohnen-moe.comwrote in message
news:5O******************************@giganews.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?
Oct 12 '08 #2

P: n/a
On 2008-10-12, Daniel Kaplan <No****@NoSpam.comwrote:
"Jim Moe" <jm***************@sohnen-moe.comwrote in message
news:5O******************************@giganews.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.
Oct 12 '08 #3

P: n/a

"Ben C" <sp******@spam.eggswrote in message
news:sl*********************@bowser.marioworld...
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.,,,
Oct 13 '08 #4

P: n/a
On 2008-10-13, Daniel Kaplan <No****@NoSpam.comwrote:
>
"Ben C" <sp******@spam.eggswrote in message
news:sl*********************@bowser.marioworld...
>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.
Oct 13 '08 #5

P: n/a

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
Oct 13 '08 #6

P: n/a
On 2008-10-13, Bergamot <be******@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.
Oct 13 '08 #7

P: n/a
Ben C wrote:
Tables are a useful part of CSS
Tables are not part of CSS. They are part of HTML.
Oct 13 '08 #8

P: n/a
On 2008-10-13, Scott Bryce <sb****@scottbryce.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.
Oct 14 '08 #9

P: n/a
In article <sl*********************@bowser.marioworld>,
Ben C <sp******@spam.eggswrote:
On 2008-10-13, Scott Bryce <sb****@scottbryce.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
Oct 14 '08 #10

P: n/a
Ben C wrote:
On 2008-10-13, Scott Bryce <sb****@scottbryce.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.
Oct 14 '08 #11

P: n/a
On 2008-10-14, Scott Bryce <sb****@scottbryce.comwrote:
Ben C wrote:
>On 2008-10-13, Scott Bryce <sb****@scottbryce.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.
Oct 14 '08 #12

P: n/a
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.
Oct 14 '08 #13

P: n/a

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
Oct 14 '08 #14

P: n/a
On 2008-10-14, Bergamot <be******@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.
Oct 14 '08 #15

This discussion thread is closed

Replies have been disabled for this discussion.