I\'m trying to style blocks of code for a website. The container div is set to overflow both vertically and horizontally. The problem is when it overflows horizontally, the zebr
Try float:left on the .codeblock pre. Works in Firefox.
fits itself inside the .codeblock container like there was no more room. float makes your element wide just enough to fit its content.
UPDATE
.codeblock pre {
float: left;
min-width: 100%;}
Works in Firefox, Opera, IE9 and WebKit
As far as I understand, it elements inside a container with overflow:auto fit themselves inside the area that's visible by default. Those elements' width:100% is only as wide as the outer container. In this example inside of the inner container you have a code tag that doesn't break lines so the text goes outside the inner container and makes the outer container show scrolls. To avoid that, you need the inner container to fit its content hence float:left.
But, as you cleverly noticed (and I didn't), this way it won't expand if the outer container is wider than the code so to avoid that you need to put min-width:100% to make the inner container use at least all the visible space inside the outer container.