Prev: Take a number and display it as KiloBytes, MegaBytes, Giga etc....
Next: Does "transitional" and/or "xhtml" hide errors?
From: Stefan Weiss on 15 Jun 2010 18:09 Is there a way to specify a top margin of an element as a percentage of a height instead of a width (either the element's or the container's)? I suspect that there isn't, and in that case I'd like to follow up with a related question: Why was it decided that a vertical dimension like a top/bottom margin should be calculated as relative to a horizontal dimension? Apart from not being very intuitive, I don't think there are very many useful applications for this rule. Seems to me it would have been more practical (for web designers, at least) if percentages in a vertical dimension had a vertical reference. I'm not looking for help with positioning any elements (I know there are other ways to do that), I'm just trying to understand the rationale for making margin-top depend on a width. -- stefan
From: Ben C on 16 Jun 2010 03:30 On 2010-06-15, Stefan Weiss <krewecherl(a)gmail.com> wrote: > Is there a way to specify a top margin of an element as a percentage > of a height instead of a width (either the element's or the > container's)? No. > I suspect that there isn't, and in that case I'd like to follow up > with a related question: Why was it decided that a vertical dimension > like a top/bottom margin should be calculated as relative to a > horizontal dimension? It is unintuitive and bizarre I agree. But margins as percentages of heights have problems of their own: the height of the container usually depends on its contents, often including their margins (except when they collapse with the margins of the container). So most of the time percentage vertical margins just wouldn't work at all. That's what CSS says happens to circular percentages generally-- they just get disregarded. So I suppose they thought it better to make them do something inappropriate rather than nothing at all, like an out-of-work astronaut who settles for a job as a web developer. Or maybe it was just a bug originally in some browser that others then copied and which then found its way into the spec after some post-hoc rationalization. > Apart from not being very intuitive, I don't think there are very many > useful applications for this rule. Seems to me it would have been more > practical (for web designers, at least) if percentages in a vertical > dimension had a vertical reference. Maybe if paragraphs are very wide and have long lines, its preferable to have bigger vertical gaps between them? > I'm not looking for help with positioning any elements (I know there > are other ways to do that), I'm just trying to understand the > rationale for making margin-top depend on a width.
From: Stefan Weiss on 16 Jun 2010 15:10 On 16/06/10 09:30, Ben C wrote: > On 2010-06-15, Stefan Weiss <krewecherl(a)gmail.com> wrote: >> Is there a way to specify a top margin of an element as a percentage >> of a height instead of a width (either the element's or the >> container's)? > > No. > >> I suspect that there isn't, and in that case I'd like to follow up >> with a related question: Why was it decided that a vertical dimension >> like a top/bottom margin should be calculated as relative to a >> horizontal dimension? > > It is unintuitive and bizarre I agree. But margins as percentages of > heights have problems of their own: the height of the container usually > depends on its contents, often including their margins (except when they > collapse with the margins of the container). Thanks. That was my impression, too. -- stefan
From: David Stone on 16 Jun 2010 16:14
In article <mJKdnbd5fPMrvITRnZ2dnUVZ8q6dnZ2d(a)giganews.com>, Stefan Weiss <krewecherl(a)gmail.com> wrote: > On 16/06/10 09:30, Ben C wrote: > > On 2010-06-15, Stefan Weiss <krewecherl(a)gmail.com> wrote: > >> Is there a way to specify a top margin of an element as a percentage > >> of a height instead of a width (either the element's or the > >> container's)? > > > > No. > > > >> I suspect that there isn't, and in that case I'd like to follow up > >> with a related question: Why was it decided that a vertical dimension > >> like a top/bottom margin should be calculated as relative to a > >> horizontal dimension? > > > > It is unintuitive and bizarre I agree. But margins as percentages of > > heights have problems of their own: the height of the container usually > > depends on its contents, often including their margins (except when they > > collapse with the margins of the container). And as a consequence of the content-dependence, often their widths too! > Thanks. That was my impression, too. |