Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Twitter Bootstrap's <pre> blocks scroll horizontally?

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?

like image 601
Suan Avatar asked Apr 29 '12 17:04

Suan


2 Answers

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; } 
like image 118
Suan Avatar answered Oct 04 '22 02:10

Suan


This worked for me:

pre {     overflow-x: auto; } pre code {     overflow-wrap: normal;     white-space: pre; } 
like image 21
Matt Morey Avatar answered Oct 04 '22 02:10

Matt Morey