문제

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

도움이 되었습니까?

해결책

Add white-space:pre to your element to preserve white-space characters.

다른 팁

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 to white-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 has white-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 the white-space property which you can also use, depending on your requirements: pre-wrap and pre-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.

<svg width="600" height="150" font-family="monospace"  xml:space="preserve">
<defs>
<style type="text/css">
<![CDATA[ /* ADD CLASSES */
.font{text-anchor: start; font-size: 12px;font-weight: normal; font-family: "DejaVu Sans Mono", sans-serif;white-space: pre-wrap;}
]]>
</style>
</defs>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top