是否可以更改 HTML 输入标记中文本的大小?
我有一位客户想要在 框中输入更大的文本。我宁愿不必为此制作自定义图形按钮,因为它位于资源真正受限的嵌入式系统上。
I have a client who wants bigger text in an <input>
box. I would prefer to not have to make custom graphic button for this as it's on a really resource-constrained embedded system.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
input
标签的样式可以像 HTML 中的任何其他元素一样设置,包括填充、边框、文本字体/大小等。或者您想要的任何样式。
The
input
tag can be styled just like any other element in HTML, including padding, borders, text font face/size, etc.Or what ever you would like.
只需指定元素所需的
font-size
:我使用了相对大小 (
em
),因此如果用户定义了较大的字体大小,则比例将保持不变在浏览器中。Simply specify the
font-size
you want for the element:I have used a relative size (
em
), so the ratio will keep if a user has a larger font size defined in the browser.您不仅应该增加
font-size
,如果输入元素没有增加height
和line-height
属性,您可能还需要增加height
和line-height
属性t 随文本缩放(取决于样式的设置方式)。另外,请务必检查所有浏览器,因为表单可能非常挑剔。not only should you increase the
font-size
, you may also have to increase theheight
andline-height
properties if the input element doesn't scale with the text (depending on how your styles were set). Also, be sure to check across all browsers, as forms can be very finicky.是的,这是可能的,而且做起来也很简单!
HTML:
和 CSS:
希望有帮助!
编辑:jsFiddle 上的示例
Yep, it is possible and also simple to do!
HTML:
And the CSS:
Hope it helped!
EDIT: Example on jsFiddle