[英]Resize text area based on content
我正在一個項目中,我需要在c#/ javascript中的Google api上添加包含很多文本的框。 問題是當我輸入更多文本時,我的文本框不會調整大小。 我正在用文本區域執行此操作。 唯一有效的時間是當我將contenteditable放入html代碼中時。 但是,我不能在我的文本區域中鍵入normaly。
這就是我目前所擁有的。 當文本比文本區域長時,我得到一個滾動條。 我已經看過使用Prototype自動調整textarea的大小,但是這些解決方案不起作用。 有人知道我該如何解決嗎?
我在C#標准網絡瀏覽器中工作,所以這意味着它是IE。
我的代碼:
//begin css
.contextComment{
height: auto;
background:#ffffff;
overflow:auto;
}
.textArea{
margin-left: 2px;
margin-top: 2px;
display:inline-block;
word-wrap: break-word;
margin-bottom: 2px;
position: relative;
overflow-y:auto;
}
textarea{
border: none;
border-color: transparent;
height: 100%;
overflow: hidden;
}
//end css and start Javascript
function showCommentContextMenu(caurrentLatLng, indexPr) {
var projection;
contextmenuDir;
projection = map.getProjection();
$('.contextmenu').remove();
contextmenuDir = document.createElement("div");
contextmenuDir.className = 'contextmenu';
contextmenuDir.innerHTML = "<div class='contextComment'><div class='textrea'><form action='' name='newTitleForm'><textarea type='text' onKeyPress='false' maxlength='1000' name='newTitle'>" + commentList[indexPr].text + "</textarea></div><div class='arrowImage'><input type='image' type='submit' alt='Verander de comment' onClick='changeComment(document.newTitleForm.newTitle.value, " + indexPr + ")' unselectable='on' src=" + arrow + "></form></div></div>";
$(map.getDiv()).append(contextmenuDir);
setMenuXY(caurrentLatLng);
contextmenuDir.style.visibility = "visible";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.