![](/img/trans.png)
[英]How to show the position of highlighted text in a textarea and editable div, in a another textarea?
[英]Make DIV stylized as textarea and containing formatted text editable
我有这个 div:
<div class="textarea"></div>
我用这个 css 将其风格化为 textarea:
.textarea {
-moz-appearance: textfield-multiline;
-webkit-appearance: textarea;
border: 1px solid gray;
font: medium -moz-fixed;
font: -webkit-small-control;
height: 28px;
overflow: auto;
padding: 2px;
resize: both;
width: 100%;
}
现在,如果我在这个 div 中添加一些 html 代码,甚至光标也不显示在那里。 我可以使这个 div 可编辑吗?
只需将contentEditable
属性更改为 true,即可排序
.textarea { -moz-appearance: textfield-multiline; -webkit-appearance: textarea; border: 1px solid gray; font: medium -moz-fixed; font: -webkit-small-control; height: 28px; overflow: auto; padding: 2px; resize: both; width: 100%; }
<div class="textarea" contentEditable="true"></div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.