html/html5 中的自定义输入文本框

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

A customized input text box in html/html5

htmlcss

提问by gopi1410

Actually, I want to implement a text box as shown in the figure:enter image description here

其实我想实现一个如图所示的文本框:在此处输入图片说明

I want that the user should be able to enter the number in the required space. Note that it would be transparent so that the background is visible. A solution involving html5 canvas would also be good.

我希望用户应该能够在所需的空间中输入数字。请注意,它将是透明的,以便背景可见。涉及 html5 画布的解决方案也不错。

So, is it possible to do this? If so, how?

那么,有可能做到这一点吗?如果是这样,如何?

回答by Christian

What have you tried so far? You pretty much answered your own question, make the input have a transparent background.

你都尝试了些什么?您几乎回答了自己的问题,使输入具有透明背景。

input {
    border: 0;
    outline: 0;
    background: transparent;
    border-bottom: 2px solid black;
    width: 20px;
}

jsFiddle

js小提琴

回答by ijse

Set <input>border be only bottom side. Here is the demo, just like your picture shows.

<input>边框设置为仅底部。这是演示,就像您的图片所示。