1

I have a lot of data (in form of plain text) to read from txt files and display in a small div column like 180 pixels wide.

Part of this text is preformatted with tabs, like:

C    1    4    1.4   6    1.5  8
HL   4.5  3    1.5   1    4    1.4
U    6    1.5  8     1    5    4.9

To display this part I used this code:

<span style="font-family: 'Courier New', Courier, monospace; font-size: 10px; white-space: pre;">
C    1    4    1.4   6    1.5  8
HL   4.5  3    1.5   1    4    1.4
U    6    1.5  8     1    5    4.9
</span>

but it is really very large for the div, and if I use a common font it will be displayed like:

C 1 4 1.4 6 1.5 8

So, what I would like to do is one or both of the following:

1) Use a condensed monospaced font, but I couldn't find the way.

2) Use a ttf font like Arial (or so), as a monospaced font.

I don't know what else I can do to reach the goal.

EDIT: I added a jsfiddle live example of what is the problem and what should be the result please go to http://jsfiddle.net/LCVwH/

Thank you very much for any suggestion.

4

2 回答 2

0
<span style="font-family: 'Courier New', Courier, monospace; font-size: 10px; white-space: pre;">

应该是这样的。

使用"你打开和关闭样式。因此,当您设置字体时,您正在关闭样式。

于 2013-09-24T10:04:58.090 回答
0

添加overflow:auto;到包含 div 是一个选项吗?我可以猜到有时您的文本无论如何都会溢出 div。

对我来说,示例中的文本不会仅在 div 处溢出font-size:9px;,这对我来说有点小。

于 2013-09-24T13:30:42.860 回答