tags:

views:

207

answers:

1

The spec says that a horizontal scrollbar is supposed to be always shown if overflow-x: scroll is set.

On my website I often post code in a <pre>-Block. As this has no predefined width, but the surrounding div does have a maximum (defined as percentage), it seems that I can not figure out how to achieve the following: In case a code block is not too wide, hide the horizontal scrollbar. If it exceeds the width, show a scrollbar. Any hints? I think I have tried most of the combinations of overflow-x and -y, but none seem to do what I want.

+2  A: 

Use:

overflow-x: auto;

auto tells the browser to only show a scrollbar if the content exceeds the width of the box.

Konrad Rudolph
Sorry, but this is incorrect, at least with FF3.5. Please look at my website to see that this does not work (for some reason).
data
Your website works for me, and I *am* using Firefox 3.5 so the problem must be elsewhere. Furthermore, I am certain that this *is* correct. Have you tried re-installing your browser?
Konrad Rudolph
Did you really check on my website? It works perfectly as long as there is no border-bottom defined. If I show a bottom border for the pre element, it gives me the scroll bar. Usually, your tip would be correct
data