问题
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