文本高度:100% [英] Textarea height: 100%

查看:152
本文介绍了文本高度:100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的小提琴: http://jsfiddle.net/e6kCH/15/

这可能听起来很蠢,但我找不到一种方法使文本区域的高度等于100%。它适用于宽度,但不适用于高度。

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...

任何想法?

推荐答案

因此,如果你想将元素扩展到视口的整个高度,你需要将你的CSS应用到 html body (父元素):

html, body {
    height: 100%;
}

#textbox {
    width: 100%;
    height: 100%;
}

CSS3的替代解决方案:如果可以使用CSS3,则可以使用视口百分比单位,并直接将文本框缩放为100%高度(和100%宽度)(jsfiddle这里)

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;
}

这篇关于文本高度:100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆