Quote:
Originally Posted by koyama
Hmm... I can follow you that the paragraph in your example holds an anonymous inline box, but I'm not sure where you spot those anonymous inline boxes in the OP's example. The text is in a span element so I would think that it wouldn't qualify as an anonymous inline box? But I could be wrong.
|
Yeah, my mistake. I think that there may be anonymous inline boxes before and after the
span element, but those wouldn’t be relevant. In the case of elmu’s code, the
span element would be equivalent to the anonymous inline box, however, so the basic explanation that I provided is still relevant. (I think, anyway.)
Quote:
Originally Posted by koyama
Yeah, that seems to be working too. The only difference between the inline version and the version using some other element with the shrink-wrap effect ( see list by Arbitrator) is that the border/padding of that “pre-formatted” inline element may partially stick out of the container in the inline version. This is probably only a minor concern in this example.
|
I’m not quite sure what you mean. I guess that you’re referring to the top and bottom borders being drawn out of view as shown in Firefox in my “Solution A”.
I do notice something weird though. When I apply Solution A, Firefox kills the line breaks before and after the
span and Opera only kills it before and reveals the background of
#text. I’m also wondering why the background of
#text and the
pre element aren’t being drawn behind the areas above and below the text before
display: inline was applied; the background properties are not inherited and those elements should contain the blank lines above and below the text…
When I apply “Solution B”, the I see the rendering of Firefox for Solution A in both Firefox and Opera.
And, as you mentioned, Internet Explorer 7 fails and wraps the line for both solutions.
Now, if I try a new solution, that I’ll call “Solution C” that involves removing both the
pre and
span elements and apply the following style rule:
Code:
*#text {
display: inline;
border: 1px solid #d0d0d0;
background: #f0f0f0;
color: #006;
white-space: pre; /* Duplicate the effect of the “pre” element. */
}
… then I get preservation of the line breaks before and after the text, as I had originally expected, in Firefox and Opera. The borders are drawn weirdly though. And, this time, Internet Explorer 7 renders a scrollbar to nowhere.
Quote:
Originally Posted by koyama
Did you notice that it isn't working in IE6 and IE7? At first I thought that it was IE that didn't support white-space: pre. But this couldn't be true because it does support it, at least partially.
|
I didn’t until now. I didn’t check anything but my own example in Internet Explorer prior to my last post. I didn’t even try Solution A or B before I posted them; I assumed that they would work based upon my live example, but I forgot to consider bugs and other weirdness.
Quote:
Originally Posted by koyama
I didn't know that there were bugs related to white-space: pre in IE, but there seem to be problems. I haven't seen it mentioned though. I will have to dig into it.
|
Yes, enough to give me a headache for now. I think that I’ll take a break and research the weirdness above later.