IE8 中的等宽字体忽略空格
tag 和 css font-family
这对我来说适用于所有浏览器,除了 IE8。
在 IE8 上,所有空格都被压缩为一个空格。 (所以列消失了)
关于 IE8 为什么这样做的任何想法?
预先感谢,
亚历克斯
I'm trying to get a monospaced asci table working, as seen here:
<pre> tag and css font-family
This works for me on all browsers, except IE8.
On IE8, the spaces all get compressed into one space. (so the columns disappear)
Any ideas on why IE8 is doing this?
Thanks in advance,
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将
white-space:pre
添加到您的元素中保留空白字符。Add
white-space:pre
to your element to preserve white-space characters.HTML 默认行为是将多个空格压缩为单个空格,除非明确告知不要这样做。
告诉它不要这样做的方法是使用 CSS
white-space
属性。您可能正在寻找的值是将其设置为white-space:pre;
,这将设置一个元素以显示所有空白而不压缩它。当然,您也可以使用
HTML default behaviour is to compress multiple white spaces down to a single space, unless explicitly told not to.
The way to tell it not to do this is to use the CSS
white-space
property. The value you're probably looking for is to set it towhite-space:pre;
, which will set a element to display all white space without compressing it.You can of course also use the
<pre>
tag itself, which haswhite-space:pre;
set by default. Note that this can be overridden in your stylesheets, so if a<pre>
tag isn't working, this is probably the reason. (if this is happening, you can use the Developer Tools window to examine the styles being applied to the element)In addition to
white-space:pre;
, there are a couple of other values of thewhite-space
property which you can also use, depending on your requirements:pre-wrap
andpre-line
.You can find out more about the differences between them, with examples, here: http://www.quirksmode.org/css/whitespace.html
Hope that helps.
我已经尝试过这个并且它有效......(也许有帮助)
然后,用样式修复其余部分。
I have tried this and it worked... (perhaps it helps)
Then, fix the rest with styles.