twitter-bootstrap 使用 Bootstrap 时如何使输入元素中的字体变大?

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

How to make the font size larger in an input element when using Bootstrap?

twitter-bootstrap

提问by Ada Lungu

I have a form with several inputs that is styled using Bootstrap.

我有一个包含多个输入的表单,使用 Bootstrap 进行样式设置。

I need to set the font size of the text input fields to something larger than usual (say 32px). This is larger than the font size that comes by default with bootstrap's input-lg.

我需要将文本输入字段的字体大小设置为比平常大的值(比如 32px)。这比 bootstrap 的默认字体大小要大input-lg

I tried changing the font-size in the input-lgclass in CSS but nothing changes.

我尝试input-lg在 CSS 类中更改字体大小,但没有任何变化。

What's the best way of achieving this?

实现这一目标的最佳方法是什么?

回答by Robin Carlo Catacutan

Font size 32px is really big for an input. I assume input-lgis the class name for that input field, so to do that add this on your css :

字体大小 32px 对于输入来说真的很大。我假设input-lg是那个输入字段的类名,所以要在你的 css 上添加这个:

.input-lg {
  font-size: 32px;
}

or

或者

input {
  font-size: 32px;
}

Update

更新

Regarding the best way to achieve it, you must set a class name for that specific input field so it won't affect other fields.

关于实现它的最佳方法,您必须为该特定输入字段设置一个类名,这样它就不会影响其他字段。

e.g.

例如

html

html

<input type="text" name="username" class="username-field input-lg" />

css

css

.username-field {
  font-size: 32px
}