我想创建一个用于键入文本的位置,如输入或textarea
与div
元素,但我不知道。如何使用div元素创建输入或文本区域(输入文本的位置)
请告诉我。
我也想要这个div
像输入的意思,当点击它光标是Blinker。
我想创建一个用于键入文本的位置,如输入或textarea
与div
元素,但我不知道。如何使用div元素创建输入或文本区域(输入文本的位置)
请告诉我。
我也想要这个div
像输入的意思,当点击它光标是Blinker。
以下是您正在查找的内容。
HTML
<div id="editable" contentEditable="true"></div>
CSS(并非必需,但只是为了让DIV的样子输入框)
#editable{
border: 1px solid black;
height: 100px;
width: 400px;
}
注:参考Aditya对Browser Comp的回答atibility。如果你想支持列表之外的任何浏览器,请不要使用它。
看看这是你想要什么:http://jsbin.com/eqEPAci/1/edit
CSS:
.styles{
height:30px;
width:286px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border: 1px solid #5E5E5E;
padding:0px 5px;
background-color: #000000;
color:#BFBFBF;
outline: none;
input-align: center;
}
.abs-centered {
margin: auto;
position: absolute;
bottom: 0;
left: 0;
top: 0;
right: 0;
}
#actual-input{
height:26px;
padding:0px;
width:100%;
color:#fff;
background-color:transparent;
border:0px;
outline-style:none;
}
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body bgcolor="#25383C">
<div class="styles abs-centered">
<input id="actual-input" name="name" type="password" placeholder="Password" autocomplete="off"/>
</div>
</body>
</html>
备选:
<div contentEditable></div>
使用contentEditable="true"
为DIV
属性是这样的:
<div contentEditable="true"></div>
但要小心,这是HTML5老的浏览器不支持它
检查这[**链路**](http://jsfiddle.net/hari_shanx/Hp87R/)。这是你想要的吗? – Harry
是的,我的朋友该怎么做? – kasiri182
请参阅下面的答案。 – Harry