强制HTML textarea使用CSS使用等宽字体 [英] Forcing HTML textarea to use a monospace font using CSS

查看:1201
本文介绍了强制HTML textarea使用CSS使用等宽字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何才能让我的文本区域使用等宽字体? 如果我理解正确,应该已经继承默认的用户代理样式,但是如果你想明确地指定一个font-family(从Stackoverflow样式表中顶起的样式)

  textarea {
font-family:Consolas,摩纳哥,Lucida控制台,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,等宽;
}

首先指定更具体的(特定于空间的)字体系列,用户代理没有可用的,它将继续尝试它们直到结束,在这种情况下,它将默认为该元素的默认用户代理字体系列,如果指定了它的话。


How can I make my text area use a monospaced font?

解决方案

If I'm understanding properly, it should already inherit default user-agent styles, but if you want to explicitly, just specify a font-family ( styles jacked from Stackoverflow stylesheet )

textarea {
  font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;
}

Specify the more specific (monospace-specific) font families first, and if the user agent doesn't have that available it will keep trying them until the end, in which case it would default to the default user agent font family for that element, if any was specified.

这篇关于强制HTML textarea使用CSS使用等宽字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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