Textarea height: 100%

匿名 (未验证) 提交于 2019-12-03 00:46:02

问题:

Here's my fiddle: http://jsfiddle.net/e6kCH/15/

It may sound stupid, but I can't find a way to make the text area height equal to 100%. It works for the width, but not for height.

I want the text area to resize depending of the window size...like it works in my fiddle for the width...

Any ideas?

回答1:

Height of an element is relative to its parent. Thus, if you want to make expand your element into the whole height of the viewport, you need to apply your CSS to html and body as well (the parent elements):

html, body {     height: 100%; }  #textbox {     width: 100%;     height: 100%; } 

Alternative solution with CSS3: If you can use CSS3, you can use Viewport percentage units and directly scale your textbox to 100 % height (and 100% width) of the viewport (jsfiddle here)

body {     margin: 0; } #textbox {     width: 100vw;     height: 100vh; } 


回答2:

You can do that :

#textbox {     position:fixed;     top:0;     left:0;     right:0;     bottom:0; } 


文章来源: Textarea height: 100%
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!