在文本框中输入文本 [英] Put text in textbox

查看:196
本文介绍了在文本框中输入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一种方法可以在文本框中放置文本,但也允许用户输入内容。我想在框中写username:,并允许用户在冒号后键入。我可以通过在文本框旁边创建一个div,使它看起来像是一个容器,但我想知道是否有一个更容易的方法,这么做是艰难的方式?感谢



编辑:我不想让文字消失。我只想让用户能够继续输入



编辑2:你不能在文本框中输入值的原因是它的形式。

解决方案

您可以这样做:

 < div> 
< label>用户名:< / label>
< input type =text/>
< / div>

CSS

  div {border:1px solid gray;} 
label {font-family:arial; font-size:.8em;}
input {border:none;}
输入:focus {outline:none;}

基本上,创建一个包含 div 并放置一个标签输入中的 div label 是留在字段中的字词。 输入已删除 border



http://jsfiddle.net/jasongennaro/rZmFx/



Fyi ...您可能需要增加输入的大小,具体取决于您要接受的字符数。


Is there a way to put text in a textbox but also allow the user to type something. I would like to write "username:" inside the box and allow the user to type after the colon. I can do this the hard way by creating a div right next to a textbox and make it look like they are one container, but I was wondering if there was an easier way? Thanks

EDIT: I don't want to text to disappear. I just want to user to be able to continue typing

EDIT 2: the reason you cant put a value in the textbox is because its a form. when the user types a username next to the value it will submit together

解决方案

You could do something like this:

<div>
    <label>Username:</label>
    <input type="text" />
</div>

CSS

div{border:1px solid gray;}
label{font-family:arial; font-size:.8em;}
input{border:none;}
input:focus{outline:none;}

Basically, created a containing div and placed a label and input in that div. label is the words that stay in the field. input has the border removed.

http://jsfiddle.net/jasongennaro/rZmFx/

Fyi... you may need to increase the size of the input, depending on how many characters you want to accept.

这篇关于在文本框中输入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆