I have a long pre block, I want it to be view in mobile browsers, such as iPhone
e.g.
a very long pre block start here here here here here here here here here here
2nd line with intent
3rd line with intent
How to make make the wordwrap, but keep the indentations?
e.g.
a very long pre block start here here here here here here
here here here here
2nd line with intent
3rd line with intent
I don’t want to have scrollbar for mobile device, so better to have some way to auto word-wrap the sentence.
The most similar method I have tried is to use CSS
pre {
white-space: pre-line;
}
But not exactly as I want as demonstrated above.
Updated: Link: http://pastehtml.com/view/bisxytioa.html
Here’s a way to do it with Javascript. This goes through the
<pre>and wraps each section in a<div>withpadding-leftequal to the number of spaces of indentation. In the demo I made the size of the<pre>the size of an iPhone screen to demonstrate the wrapping.Demo:
Script:
HTML:
CSS:
Output: