*Cameron McCormack* <cam-news (AT) aka (DOT) mcc.id.au>:
Quote:
I have a page[1] in which I've got some code snippets inside a pre
within a div, but the text on some lines (if the window is narrow
enough) goes over the edge of the div. |
In CSS3 there'll probably be "white-space: pre-wrap" (among similar stuff),
which rewraps while letting the whitespaces remain intact. (Opera has
already been supporting it for several version, currently as '-o-pre-wrap'.)
Quote:
Is there a way I can get the div to appear wider to accommodate the text? |
You could count the amount of characters in the longest code line and set a
fixed width for 'pre': the number of characters with 'ex' as the unit.
That's not exact, but comes close with many fonts. (AFAIK Gecko also
supports 'ch', which stands for "character", and should give better results,
but isn't in the standard, not even proposed.)
Otherwise the width is determined by paddings, borders, margins and widths
of itself and the containing boxes (div.code, div.main, body, html, the
viewport).
Hackish, but somehow working in actual browsers is floating 'pre' or
'div.code' without a given width opposed to the requirement of the spec. By
the way, why don't you use 'pre.code'?
P.S.: Your alt texts are not so good, e.g. try "" and "XML file → XSLT
%rarr; SVG file" for the first two. Horizontal OR vertical layout should be
enough, too.
--
Sig for rent. Good as new.
4 lines á max. 80 letters.
¤ 0,02/post