3 ms·
Thanks for applying the change! I now see, though, that on a single-line my Firefox [Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/2007112
by gojomo 19y ago
Thanks for applying the change!
I now see, though, that on a single-line my Firefox [Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11] for some reason only clips, rather than adding the intended scrollbar. For example:
Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor
As soon as there's more than one line in the PRE, the expected scrollbar appears:
Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor Lorem ipsum dolor
Lorem ipsum dolor
The CSS change helps in the common multiline case but could still be improved. Tinkering a bit, I find adding a small padding helps trigger the scrollbar. Specifically, try this:
pre {overflow:auto; padding:2px}
Unsure why this is necessary, suspect a browser limitation, where only a vertical trigger causes both horizontal and vertical scrollbars to be considered.
Oh, and I also see it doesn't help at all in IE7, but at least it leaves things no worse. Can't help there, IE users are on their own.
- pg 19y agoI added the padding and now the scrollbar appears in my browser for one line examples. I think I actually like it best with cropping instead of the scrollbar. The curious can still get at the text by widening the browser or copying and pasting. Is there any way to get just cropping?
- gojomo 19y agoCSS property overflow:hidden ...should just crop. If the transition text-jump isn't too annoying, this might also be interesting: pre {overflow:hidden; padding:2px} pre:hover {overflow:auto} PRE blocks would be clipped until mouseover, when a scrollbar would appear if necessary (bumping following text down).
- pg 19y agoI just added your solution (handy to have a repl in the server) and it works well. Thanks very much; this had been bugging me for a long time.
- ingenium 19y agoIt works fine in Opera, but it still makes the whole window scroll on the newest nightly build of Firefox 3 like before the patch was applied. Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b3pre) Gecko/2007122605 Minefield/3.0b3pre