At this time, you can use overflow:auto; (when the code exceeds the container boundary, the scroll box is displayed), but this method is not applicable to all mainstream browsers, and some browsers will directly truncate the exceeded content.
We all know that the <pre> tag defines preformatted text, and a common application is to represent the source code of a computer. Text surrounded by pre elements usually retains spaces and line breaks, but unfortunately, when you write code in the <pre> tag, it will also keep it for you without wrapping it automatically if you don't wrap it manually.
At this time, you can use overflow:auto; (when the code exceeds the container boundary, the scroll box is displayed), but this method is not applicable to all mainstream browsers, and some browsers will directly truncate the exceeded content.
Since there are not many places using source code in this site, I didn’t care much about this issue before. Not long ago, an enthusiastic netizen reported this issue on QQ, so when I changed the topic this time, I looked for a solution and shared it.
Copy the code