Per the examples https://getbootstrap.com/docs/4.3/content/code/#code-blocks, bootstrap only supports vertically-scrollable and word-wrapped <pre>
blocks out of the box. How do I make it so that I have horizontally-scrollable, unwrapped code blocks instead?
The trick is that bootstrap overrides both the white-space
and the CSS3 word-wrap
attributes for the <pre>
element. To achieve horizontal scrolling, ensure there's this in your CSS:
pre {
overflow: auto;
word-wrap: normal;
white-space: pre;
}