我試圖在textarea
的底部添加覆蓋框。定位覆蓋框很簡單,但現在我想要textarea
內容不會覆蓋覆蓋框。避免textarea內容與底部覆蓋框重疊
我的第一種方法是添加padding-bottom
,以便文本永遠不會到達放置覆蓋框的textarea
的底部。但是,當我輸入時,文本將會在它下面。此外,向上滾動會導致相同的不良行爲。
編輯:
迴應部分解決我的問題的答案。我試圖讓textarea看起來儘可能原生,所以邊框顏色在焦點上的變化也是必要的。
.container {
position: relative;
width: 110px;
}
textarea {
width: 100%;
height: 50px;
resize: none;
}
texarea.with-padding {
padding-bottom: 1em;
}
span {
position: absolute;
bottom: 5px;
width: 100%;
height: 1em;
background: rgba(255,0,0,0.5);
}
<div class="container">
<textarea name="" id="">I want this to never go under the red box.</textarea>
<span></span>
</div>
<div class="container">
<textarea class="with-padding" name="" id="">I tried with padding-bottom, but it doesn't work either.</textarea>
<span></span>
</div>
設置爲邊框無文本區域,並添加邊框容器假textarea的邊框。 –
使用比底部稍大的填充產生:http://codepen.io/anon/pen/dOYVEJ - 這是你想要實現的嗎? –