jquery - 通过 jQuery 在 CSS 代码 .load()ed 中看不到换行符

标签 jquery css line-breaks

我正在使用 jQuery 将 CSS 文件的内容 .load() 到 div 中。但是当加载该文件的内容时,所有换行符、制表符等都消失了。有没有办法在保留换行符的同时加载 css 文件?

提前致谢!

最佳答案

而不是 <div>只需使用 <pre> element要保留格式,您可以 .load() 以完全相同的方式进入它。

HTML 的默认行为是不显示换行符、额外空格等(<pre></pre> 除外)、from the HTML4 spec :

For all HTML elements except PRE, sequences of white space separate "words" (we use the term "word" here to mean "sequences of non-white space characters"). When formatting text, user agents should identify these words and lay them out according to the conventions of the particular written language (script) and target medium.

关于jquery - 通过 jQuery 在 CSS 代码 .load()ed 中看不到换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3277930/

相关文章:

javascript - 未捕获的类型错误 : cannot call method 'cookie' of undefined

javascript - 如何使用 Javascript 隐藏页面加载时的特定句子

html - Rails 4 Bootstrap 部分样式

html - CSS 选择器中的通配符以匹配名称变体

javascript - 使用 JavaScript 将模板文字添加到 html 时保留换行符

encryption - OpenSSL 一行 base64 输入。读取输入文件时出错

jquery - symfony2使用ajax模拟多个提交按钮

javascript setInterval没有按时运行

html - 收缩时 Div 不会 100% 填满容器

html - Chrome 中 br 的边距