让我们假设在foo.html文件中有这样的文本:
All the World's a Stage
All the world's a stage,
And all the men and women merely players;
They have their exits and their entrances,
And one man in his time plays many parts,
His acts being seven ages. At first, the infant,
Mewling and puking in the nurse's arms.
Then the whining schoolboy, with his satchel
And shining morning face, creeping like snail
Unwillingly to school. And then the lover,
Sighing like furnace, with a woeful ballad
Made to his mistress' eyebrow.注意空格和断线。我能把它放到一个div中并保存它吗?当您将所有文本放入HTML页面时,都不会将所有文本放在一起:
All the World's a Stage All the world's a stage, And all the men and women merely players; They have their exits and their entrances, And one man in his time plays many parts, His acts being seven ages. At first, the infant, Mewling and puking in the nurse's arms. Then the whining schoolboy, with his satchel And shining morning face, creeping like snail Unwillingly to school. And then the lover, Sighing like furnace, with a woeful ballad Made to his mistress' eyebrow.我想我想要的是一个非常接近<pre>标签的行为。
发布于 2015-03-02 17:31:45
将white-space: pre应用于div元素。
空格序列被保留,行仅在源和元素中的换行符处中断。
文档:https://developer.mozilla.org/en-US/docs/Web/CSS/white-space
发布于 2015-03-02 17:35:46
嗯..。行为类似于<pre>标记,以完成<pre>标记所做的工作。也许是<pre>标签?只是开个玩笑罢了
<pre>
All the World's a Stage
All the world's a stage,
And all the men and women merely players;
They have their exits and their entrances,
And one man in his time plays many parts,
His acts being seven ages. At first, the infant,
Mewling and puking in the nurse's arms.
Then the whining schoolboy, with his satchel
And shining morning face, creeping like snail
Unwillingly to school. And then the lover,
Sighing like furnace, with a woeful ballad
Made to his mistress' eyebrow.
</pre>
<pre>标记定义预先格式化的文本。阅读更多的这里。
有什么理由不能使用这个吗?
https://stackoverflow.com/questions/28815926
复制相似问题