< pre>标签和css字体族 [英] <pre> tag and css font-family

查看:136
本文介绍了< pre>标签和css字体族的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有html的代码如下:

I have html with code below:

<pre>
                                      |       Date Offense |       Count |
   Title, Section & Nature of Offense |          Concluded |   Number(s) |
--------------------------------------------------------------------------
              18:2113(a)-BANK ROBBERY |   January 27, 2009 |           I |
--------------------------------------------------------------------------

</pre>

它在一个简单的页面中工作得很完美,但是当我添加了css和 font-family 定义,
它执行丑陋,格式不整洁了。

It works perfect in a simple page, but when I have added css with font-family defination, it performs ugly, the format is not tidy any more.

有任何建议吗?谢谢!

推荐答案

您必须使用等宽字体(也称为打字机字体)。这是一种所有字符占用相同空格的字体。

You must use a monospace font (also known as typewriter font). That is a font in which all the characters take the same space.

在CSS中,字体名称 monospace 到用户系统上的默认monospace字体。将 monospace 包含在< pre> 元素的font-familly列表的结尾是个好习惯,

In CSS the font name monospace is translated to the default monospace font on the user system. It's good practice to include monospace at the end of a font-familly list for the <pre> element so that it can be used as a fallback.

例如:

pre {font-family: Consolas,monospace}

将使用Consolas等宽字体到默认值。

will use the Consolas monospace font if it's available or fallback to the default.

这篇关于&lt; pre&gt;标签和css字体族的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆