CSS、文本区域和 iframe - 高度 %s
我目前有一个包装 div,它有两个子元素:div left 和 div right。在 div left 中,我有一个文本区域;在 div 右边我有一个 iframe。
我希望两个孩子的身高都是80%。以下是我正在使用的相关标签:
body {
height: 100%;
}
iframe {
height: 80%;
}
textarea {
height: 80%;
}
正如我所期望的,iframe 占据整个页面宽度的 80%,但是 textarea 并没有一直占据页面的 80%。我发现它占据了 div left 高度的 80%,并且将 div.left 高度设置为 100% 并不会使 textarea 占据它需要的所有空间。
有什么建议吗?
I currently have a wrapper div that has two children: div left and div right. In div left, I have a textarea; in div right I have an iframe.
I'd like both children to have 80% height. Here are the relevant tags I'm using:
body {
height: 100%;
}
iframe {
height: 80%;
}
textarea {
height: 80%;
}
The iframe goes 80% of the entire page width, as I'd expect, but the textarea doesn't go all the way to 80% of the page. I've found that it goes 80% of div left's height, and setting div.left height to 100% doesn't make textarea take up all the space it needs to.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为高度属性通常会随着内容的增长而增长。因此,您可以使用 javascript 计算确切的高度并将文本区域设置为那么多像素。
Because a height property usually grow up with the contents. So you can use javascript to calculate the exact height and set the textarea to be that many pixels.