Textarea 100% height in IE

青春壹個敷衍的年華 提交于 2019-12-13 17:16:32

问题


How do I get my <textarea> to have a height of 100% and work in IE7/6? height:100% works fine in all other browsers but IE just doesn't want to accept anything other than specific values. Javascript is a possible solution.


回答1:


In order for an element to achieve 100% height in IE6, you will need to specify a fixed height of its parent element. If you want to make the element the full-length of your page, apply height:100%; to both the html and body elements.

/*100% height of the parent element for IE6*/ 
#parent {height:500px;}
#child {height:100%;}

/*100% of the page length for IE6*/ 
html, body {height:100%;}
#fullLength {height:100%;}

Taken from: http://www.virtuosimedia.com/

I'm guessing the same applies for IE7.




回答2:


I want to leave an answer here, beacause I have the same problem and answer above is not fully helpfull.

For all browsers except IE6-7

  div#parent {height:500px;}
  textarea#child {height:100%;}

But for IE6-7 you need to set:

  textarea#child {
      height:100%;
      position: absolute;
  }


来源:https://stackoverflow.com/questions/3036109/textarea-100-height-in-ie

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