Html 更改文本输入标签中文本的大小?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10363674/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:02:12  来源:igfitidea点击:

Change size of text in text input tag?

htmlcss

提问by Dragan Marjanovic

I have a large input box for text but I can't change the font size?

我有一个很大的文本输入框,但我无法更改字体大小?

<input type="text">

<input type="text">

I would like to change the font size inside the text field but I can't seem to do it using CSS. Any help?

我想更改文本字段内的字体大小,但我似乎无法使用 CSS 来做到这一点。有什么帮助吗?

回答by nullpotent

<input style="font-size:25px;" type="text"/>

<input style="font-size:25px;" type="text"/>

The above code changes the font size to 25 pixels.

上面的代码将字体大小更改为 25 像素。

回答by Hymantheripper

In your CSS stylesheet, try adding:

在您的 CSS 样式表中,尝试添加:

input[type="text"] {
    font-size:25px;
}

See this jsFiddle example

请参阅此 jsFiddle示例

回答by Jim D

This works, too.

这也有效。

<input style="width:300px; height:55px; font-size:50px;" />

A CSS stylesheet looks better though, and can easily be used over multiple pages.

不过,CSS 样式表看起来更好,并且可以轻松地在多个页面上使用。

回答by Aaron

The Javascript to change font size for an input control is:

更改输入控件字体大小的 Javascript 是:

input.style.fontSize = "16px";

回答by Robert Barros

I would say to set up the font size change in your CSS stylesheet file.

我会说在您的 CSS 样式表文件中设置字体大小更改。

I'm pretty sure that you want all text at the same size for all your form fields. Adding inline styles in your HTML will add to many lines at the end... plus you would need to add it to the other types of form fields such as <select>.

我很确定您希望所有表单字段的所有文本都具有相同的大小。在您的 HTML 中添加内联样式将添加到最后的多行...此外,您还需要将其添加到其他类型的表单字段中,例如<select>.

HTML:

HTML:

<div id="cForm">
    <form method="post">
        <input type="text" name="name" placeholder="Name" data-required="true">
        <option value="" selected="selected" >Choose Category...</option>
    </form>
</div>

CSS:

CSS:

input, select {
    font-size: 18px;
}

回答by Nikola Radovancev

Change your code into

将您的代码更改为

<input class="my-style" type="text" />

CSS:

CSS:

.my-style {
  font-size:25px;
}

回答by S.Nirmala Josphine

To change the font size of the <input />tag in HTML, use this:

要更改<input />HTML 中标记的字体大小,请使用以下命令:

<input style="font-size:20px" type="text" value="" />

It will create a text input box and the text inside the text box will be 20 pixels.

它将创建一个文本输入框,文本框内的文本将为 20 像素。