如何更改 HTML 输入标签的字体和字体大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8083430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change the font and font size of an HTML input tag?
提问by Cocoa Dev
<input id="txtComputer">
How do I make my text inside the input tag bigger? I want to make it 24 size font. It would also be good if I can change the font from the default
如何使 input 标签内的文本变大?我想让它变成 24 号字体。如果我可以更改默认字体也很好
回答by tmjam
<input type ="text" id="txtComputer">
css
css
input[type="text"]
{
font-size:24px;
}
回答by AlQafir
In your 'head' section, add this code:
在您的“头部”部分,添加以下代码:
<style>
input[type='text'] { font-size: 24px; }
</style>
Or you can only add the:
或者您只能添加:
input[type='text'] { font-size: 24px; }
to a CSS file which can later be included.
到以后可以包含的 CSS 文件。
You can also change the font face by using the CSS property: font-family
您还可以使用 CSS 属性更改字体:font-family
font-family: monospace;
So you can have a CSS code like this:
所以你可以有这样的 CSS 代码:
input[type='text'] { font-size: 24px; font-family: monospace; }
You can find further help at the W3Schoolswebsite.
您可以在W3Schools网站上找到更多帮助。
I suggest you to have a look at the CSS3 specification. With CSS3 you can also load a font from the web instead of having the limitation to use only the most common fonts or tell the user to download the font you're using.
我建议你看看 CSS3 规范。使用 CSS3,您还可以从 Web 加载字体,而不必限制只能使用最常用的字体或告诉用户下载您正在使用的字体。
回答by CAP
in your css :
在你的 css 中:
#txtComputer {
font-size: 24px;
}
You can style an input entirely (background, color, etc.) and even use the hover event.
您可以完全设置输入的样式(背景、颜色等),甚至可以使用悬停事件。