如何使用CSS获取具有等宽文本的HTML文本区域? [英] How do I get an HTML Text Area with monospaced text using CSS?

查看:148
本文介绍了如何使用CSS获取具有等宽文本的HTML文本区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个愚蠢的noob问题,但我不知道如何使我的文本区域使用等宽字体。

This may be a dumb noob question, but I can't figure out how to make my text area use a monospaced font.

推荐答案

如果我的理解正确,它应该已经继承默认的用户代理样式,但是如果你想显式地,只需指定一个字体族(从Stackoverflow样式表填充的样式)

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.

这篇关于如何使用CSS获取具有等宽文本的HTML文本区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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