簡體   English   中英

如何更改textarea調整大小的位置?

[英]How to change the position of textarea resizing?

我有一個像這樣的簡單textarea

<textarea name="txtarea" cols="14" rows="4"></textarea>

上面textarea的形狀和位置是右下角,像這樣:

當前形狀

現在我想知道我怎樣才能把它改成這個?

我想要的是

您可以使用這個簡單的JQuery工具來調整textarea大小。

使用代碼片段

 var KeyDown; $(".TxtArea > div").mousedown(function() { $(this).parent().addClass("Resize"); $("body").addClass("UnSelectable"); KeyDown = 1; }); $(document).mouseup(function() { $(".TxtArea").removeClass("Resize"); $("body").removeClass("UnSelectable"); KeyDown = 0; }); $(document).mousemove(function(Event) { if (KeyDown == 1 && $(".TxtArea").hasClass("Resize")) { var Height = Event.pageY - $(".TxtArea").children("textarea").offset().top; $("textarea").height(Height); } });
 .TxtArea { width: 300px; } .TxtArea > textarea { width: 100%; display: block; resize: none; box-sizing: border-box; } .TxtArea > div { height: 10px; background: #eee; border: 1px solid #ddd; box-sizing: border-box; text-align: center; line-height: 0px; } .TxtArea > div:hover { cursor: n-resize; } .UnSelectable { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script> <div class="TxtArea"> <textarea></textarea> <div>.....</div> </div>

或者JSFiddle

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM