开发者

HTML textarea styles

Let's say within the <body> of my web page, all I have is a <textarea> element.

This <textarea> should be as wide and tall as the browser window (minus any padding or margin the &开发者_如何转开发lt;body> has, or any default computed styles per browser).

I can make it as wide as the window by setting display:block;width:100%, but it doesn't stretch to the height of the window (see http://jsfiddle.net/4MBAs/) when I include height:100%.

How can I stretch the height out to reach the bottom of the browser—without having to use JavaScript?


you have to set height:100%; on body and html too.

try it like this:

body, html {
  height: 100%;
}

textarea {
  height: 100%;
  width: 100%;
}


Here's an alternative:

textarea {
  position: absolute;
  bottom: 0px;
  top: 0px;
  left: 0px;
  right: 0px;
}

That does not preserve the body padding, though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜