![](/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.