Re: We can't center vertically if we don't know the height of the box and container

On 5 January 2012 13:00, Matthew Wilcox <mail@matthewwilcox.com> wrote:
> Thanks for the pointers.
>
> I have misgivings about both of those modules to be honest. In my
> opinion they over-complicate things, especially for this particular
> use case.
>
> With regard to layout in general I would far rather see CSS able to
> inspect other elements properties and apply those back to the
> reference element, because it allows all the control you need without
> introducing large, complicated new syntax.
>
> That fact is this: there's a vertical-align property and it has a
> value of middle. It is entirely natural and reasonable to expect this
> to center a box vertically. There is no reason to complicate things
> further by telling people that this won't work and instead use an
> entire new module to do what that simple statement makes intuitive.
>

Personally I'm not keen on the idea of referencing between elements. I
think it could be useful in some cases, but it seems like it has the
potential to create very hacky and difficult to understand designs,
because authors will need to keep track of all the inter-dependencies
between elements. I think grid based layouts are better: they are
easier to visualise and understand, they fit better with how graphic
designers create interfaces, and they are much more amenable to
tooling.

Regarding vertical-align, I believe it is complicated due to the
nature of the default CSS formatting model, whereby elements are "in
flow" within a document, so you can't just move them around
arbitrarily. I suppose vertical-align could extended so it could
center absolutely positioned elements or floats. However, I think
using absolute positioning and float-based layout will become
something on an anti-pattern as newer layout techniques, based on
grids, flexible boxes, and regions become available.

I can understand how these new modules may seem over-complicated and
very different, but that is because they are trying to solve problems
of layout, alignment and positioning in the general case, rather than
the specific case of vertical centering. While vertical alignment is a
pain point, it is far from the only problem with CSS layout as it
stands. The idea is that these new approaches will replace all the
floating and clearing, margin/padding and positioning hacks that
authors currently use to get around the fact that CSS was never
designed with laying out pages in mind. I'd urge you to investigate
and experiment with them with an open mind.

Thanks,

Jon

Received on Thursday, 5 January 2012 16:39:37 UTC