In article <
MPG.2944f52c8...@news.demon.co.uk>,
bounc...@you.com says...
>
> Nb: I'm no expert in CSS, and I may be missing something really dumb.
>
> Here's what I want to do, in code (with an invented value for
> "display"):
>
>
> <div id="This-is-a-left-floated-image"
> style="float:left; height: 200px; width: 200px">
> <img src="myImage.jpg">
> </div>
>
> <div id="I-want-this-to-stay-rectangular"
> style="display: be-a-rectangle-dammit !important">
> <p>several lines of text</p>
> </div>
>
>
> I've tried everything (?) to achieve this: I want to be able to force a
> block of text (which might be a single paragraph or may include headers
> or lists) NOT to wrap round the bottom of a left-floated image but to
> have each new line start at the same horizontal distance from the left
> edge of the viewport even if it has run below the floated image.
>
> If all I had on the page were small-ish images, it would be easy - I'd
> just float everything :left and they would pack themselves across the
> viewport until there was no room for another and then start a new line
> of images. Nothing would "shear" so that part was to the right of the
> preceding element and part was underneath. I want exactly that for
> text.
>
> I'm working on a page which has a map (of Epping Forest), an intro, and
> a dozen similar descriptions of a monthly "walk" (each is currently a
> div with an h2, h3 and a couple of p). I'd like the "walk" divs to wrap
> around the map without any of them going L-shaped.
>
> Is that so hard? (I guess...)
>
> One thing I came up with was to make the image a background-image, and
> to duplicate the div, so that each appeared twice. The first copy is
> cleared :both and floated :left, and I set width and padding by
> percentage so that both would squish up nicely as the window is squished
> up. Then I set the left-hand one to have visibility: hidden, and all
> you see is the right-hand one. It doesn't "shear", as the thing it's
> being floated round is guaranteed to have the same dimensions. Thought
> I was pretty smart with this dodge. Initially.
>
> But it doesn't scale. As you pass the bottom of the map there is now
> room for two of these "walk" divs (in a typical window width) but this
> (crazy?) method just leaves a big gap (where the hidden div is lurking).
>
> What I want is a truly fluid layout, so I can start with full-screen on
> my huge monitor and then squish it narrower and have everything slot
> into place in the space available without any of my "walk" divs
> "shearing" (wrapping partly under its neighbour on the left).
>
> How can I do this? Make an old fool happy...
> There's a demo page of what I'm after here:
>
http://www.rwsbs.co.uk/floats/div-test.htm
Thanks very much indeed for the patient and wise responses I've received
to a problem that has driven me potty since I started playing with
Floats (surely the first positional technique anyone tries).
This demo page shows what I didn't want:
http://www.rwsbs.co.uk/floats/div-test.htm
Ben and others mentioned the 'overflow' attribute, and Block Formatting
Contexts. This page shows my first use of it:
http://www.rwsbs.co.uk/floats/div-test-overflow.htm
... it seems to be doing what I want.
My first (tortuous) attempt to achieve this effect had been to duplicate
or "mirror" the blocks I wanted to prevent from 'shearing' (see earlier
message for my explanation of this term) and to set visibility:hidden
for the place-holding duplicates. As the viewport was squished and
stretched the mirror block would necessarily claim the same vertical
space but would not be visible. It sort of worked (but always had to be
a lunatic way to do this):
http://www.rwsbs.co.uk/floats/index-visibility-hidden.htm
(in these examples I've moved the CSS into the same file in case anyone
wants to follow it without having to track down my external stylesheet.)
I also experimented with a solution based on tables. It *sort of* got
there, but clearly lacks the flexibility of a floated approach:
http://www.rwsbs.co.uk/floats/index-table.htm
(I've left the borders at 1px so you can see where things are easily.)
But it looks like this is the basis of a solution:
http://www.rwsbs.co.uk/floats/index-spacers-overflow.htm
I've used a couple of transparent, sized "spacer" DIVs, both floated
left, above the map which is a background-image to an encompassing DIV.
I've contained the multiple 'walk' DIVs in a DIV id="walks", and set
overflow:hidden on that outer one. Toggling that overflow value between
hidden & visible is enough to inflict and remove the 'shearing' that I
dislike so much (although you might notice that it looks fine in the
'intro' DIV which precedes the walks.
Yes, I might instead have 'sliced' the map and used the slices in the
foreground, but I rather think the use of a background-image has less
complexity overall.
Obviously there is a lot of cosmetic attention needed before I'd want
anyone other than a CSS-head to see it, but I'm satisfied that it's the
basis of a solution. I'm now ruminating over whether (and how) to fill
the blank spaces which emerge at some window dimensions - perhaps a
repeated washed-out background image (but that's another story). You'll
see I've emphasised the structure for anyone interested with otherwise
superfluous borders and 'labels'.
I'll have fun tinkering with this over the rest of the month, and with a
bit of luck it'll soon be incorporated into the main website for the
"Friends..." (normally maintained by a good and decent chap who has
declared he'll get by without CSS altogether).
Best wishes to all; very happy to make your acquaintance.
Phil
--
Phil, London