我有一個包含textarea的div。這個div有一個邊框:1px純黑色。現在,當用戶輸入textarea時,textarea會增長。如何更改div高度增加的邊框
我有這樣的代碼 -
$('#sendtext').on('input', function(){
$this = $(this);
var totalHeight = $this.prop('scrollHeight') - parseInt($this.css('padding-top')) - parseInt($this.css('padding-bottom'));
$this.height(totalHeight);
$div = $('#sendmsg');
$div.height($div.prop('scrollHeight') - parseInt($div.css('padding-top')) - parseInt($div.css('padding-bottom')))
});
現在外層div(外到textarea的)增長它。但這種高度變化並未體現在邊界上。邊界停留在那裏。如果可能的話,我怎麼能做到這一點。
PS - 當我在我的Chrome(Ctrl + Shift + I)中看到我的外部潛水長高時,但邊界不能反映這種變化。
HTML -
<div id="sendmsg">
<textarea id="sendtext" value="">
</textarea>
<div class="clearBoth"></div>
</div>
CSS -
#sendmsg{width:100%; height:auto;}
#sendtext{width:95%; margin:10px; padding:5px; transition: width 0.25s; resize:none; overflow:hidden;}
.clearBoth{clear:both;}
你可以請顯示HTML或包含一個例子(例如來自JSFiddle)?這會使答案更容易。 –
請將HTML和CSS代碼放在這裏 – khurram
添加了HTML和CSS –