la police Monospace dans IE8 ne tient pas compte des espaces
-
25-10-2019 - |
Question
Je suis en train d'obtenir un travail de table ASCI à espacement fixe, comme on le voit ici:
et css font-family
Cela fonctionne pour moi sur tous les navigateurs, sauf IE8.
Sur IE8, les espaces tout se compressés dans un seul espace. (De sorte que les colonnes disparaissent)
Toutes les idées sur les raisons IE8 fait cela?
Merci à l'avance,
Alex
La solution
Add white-space:pre
to your element to preserve white-space characters.
Autres conseils
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>