B
Ben C
Ben C said:[...]
Now to matters more curious to me:The point of the canvas is this.
I am still looking at your explanation, Ben. Take the delay as a
compliment. The martian brain is a bit different to the earthling
one and so please be patient.
The key point to consider is this: if you put a background image
(something anisotropic, like an actual picture, not just a solid colour)
on the body element, and then scroll the page, the image moves as the
page scrolls.
That is what browsers have been doing since before the days of CSS, but
it's actually very weird behaviour and there's no way to get that
behaviour with CSS except on the root element with the special rules for
the root element.
The reason is that the region that that image is tiling is not the
padding box of any particular element: it's the bounding box of the root
element and all its descendents. That's the so-called "canvas". For
every other element, you can only put backgrounds on padding boxes.
Put a background image on a div with overflow: scroll and there's no
way you can make the image move when the div scrolls.
I am resisting impudently suggesting models I have had in mind
until I see a bit more what the models have to account for.
Obviously in my practice, I have been able to get by on very
simple models with the html element as not different to the
viewport much (at least the bit of it that is not holding the
head). I have operated on a sort of "Headless Chook" model (body
being the important bit) to date and it has served me well. But I
have tastes in the non-practical areas of life and to these I
will turn my attention as I get time. <g>
The viewport is basically the browser window (or the edge of a
frame/iframe) and it has a size which the user sets.
Behind the viewport, as it were, is the canvas. The canvas is often
bigger than the viewport, but you can move it around behind the viewport
by scrolling, so you can see different bits of it through the viewport.
On top of the canvas is the root element. Inside the root element is
body, and all the other elements are inside body. The root element and
everything below it all get widths and heights according to the proper
CSS rules, with the viewport width as the width of the "initial
containing block".
So since width is auto by default, they all start off the same width as
the viewport, minus the horizontal borders/padding/margin of their
ancestors. Everything flows into the width available to it, usually not
taking up more width, but dropping down if it needs to. Of course
sometimes things will take up more width-- when authors have explicitly
set widths, or written lines that are too long to break into the space,
etc. Often things take up more height.
So often you end up with the root element and all its descendents taking
up a larger-than-viewport-sized region of the canvas. If this has
happened, you get to scroll (usually).
The root element's background is thought of as painted onto the canvas,
not onto the root element's padding box (where it would normally go). It
extends infinitely (or at least as far as you can scroll). This is so
that when you scroll, the root element's background moves with its
contents and doesn't run out.