css – Scroll code block instead of wrapping text


I’m including some code in a blog post and the length of some lines causes text to wrap, which I don’t want.wrapped text code

I’d like to have the sort of thing which can be found here on stackexchange, where a scroll bar is added for long code to prevent line breaks.

tttttttttttttthhhhhhhhhhhhhiiiiiiiissssssssssssssssss iiiiiiiiiiiiiiiiiissssssssssssssssss vvvvvveeeeeeeerrrrrrrryyyyyyyyy llllllllooooooonnnnnnnnnnnnnggggggggggg

After some research I’ve tried adding this custom CSS class:

.scroll {
  white-space: pre;
  overflow-x: scroll;

But this has had no effect on the code block. What should I do?

fon01234 4 months 2022-03-25T22:04:04-05:00 0 Answers 0 views 0

Leave an answer