html - 段落预格式化后保持正常文本字体

标签 html css pre

我有以下代码,我正在尝试测试如何在我的网站上使用预格式。包含 pre 之后,字体会发生变化并且线条不会中断以适应 200px 的划分。我想保持默认的字体大小、样式和系列。 注意:我不想使用溢出方法。 我想要这样的输出

"Sometimes it is very hard to code but by
 circumstance you find yourself struggling 
to fit in the game .
Awesome feelings come and disappear.
Niggas say this game is for the patient hearts.
 You nigga is this true??
  Nigga love style
 keep in touch with us at any given time"

加上默认的文字字体

<html>
    <head>
       <title>Test</title>
    <style>
    {
      pre{
    font-family: monospace;
    text-wrap: unrestricted;
    }
    }
    </style>
    </head>
    <body>
    <div style='width:200px;'>
      <pre>Sometimes it is very hard to code but by circumstance you find yourself struggling to fit in the game .Awesome feelings come and disappear.Niggas say this game is for the patient hesrts .. You nigga is this true??
    Nigga love style
    keep in touch with us at any given time</pre>
    </body>
    </html>

请帮我解决这个问题

最佳答案

此解决方案是否符合您的需求? <div style="white-space: pre-wrap;">content</div>

我在这里看到了 link

关于html - 段落预格式化后保持正常文本字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33716933/

相关文章:

javascript - 更改 div 的 css 类然后改回

html - 如何使 iframe 静音?

html - 折叠的表单控件在大小调整期间正在更改其属性

javascript - 如何在我的 html 页面底部删除多余的空白空间和滚动条?

html - 精确的行高

javascript - 在javascript中着色字符串的中间

html - 在网格中平均分配固定宽度的 div

javascript - 如何访问对象标签中加载的 HTML 元素?

google-chrome - chrome 26.0.1410.43 中与旧版本的渲染差异

html - 预标记在移动设备中没有响应