本文介绍了如何在< code>中保留换行符堵塞?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些代码示例要发布在HTML文档中.我用<code>
标签将它们包装起来,但我希望它们的样式设置为保留换行符.我可以通过用<pre>
标记将它们括起来来做到这一点,但是我更喜欢使用CSS.
I have some code samples which I want to publish in an HTML document. I'm wrapping them with <code>
, tags but I'd like them to be styled such that line breaks are preserved. I can do this by also enclosing them with <pre>
tags, but I'd prefer to use CSS.
我已经尝试在IE7中进行以下操作(根据此参考应该可以正常工作),但没有任何乐趣(删除了换行符):
I've tried the following in IE7 (which according to this reference should work), but with no joy (line breaks are stripped):
code {
white-space: pre;
}
这可能吗?
推荐答案
检查您的文档类型是否有效并在第一行.也许它正在进入怪癖模式?
Check your doctype is valid and on the first line. Maybe it's slipping into quirks mode?
这篇关于如何在< code>中保留换行符堵塞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!