CSS、文本区域和 iframe - 高度 %s

发布于 2025-01-05 05:29:20 字数 398 浏览 2 评论 0原文

我目前有一个包装 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抚笙 2025-01-12 05:29:20

因为高度属性通常会随着内容的增长而增长。因此,您可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文