CSS可滚动百分比div
我有一个 div,我想要一个垂直滚动条。
到目前为止,我已经使用了以下 css,效果很好:
.mywrapper {
max-height: 300px;
overflow: auto;
}
但是,我希望 div 占据页面上尽可能多的垂直空间。由于这是页面上的最后一个 div,如果可能的话,我希望它一直延伸到底部。
I have a div that I'd like to have a vertical scrollbar.
So far, I have used the following css, which works fine:
.mywrapper {
max-height: 300px;
overflow: auto;
}
However, I would like the div to take up as much vertical space on the page as possible. Since this is the last div on the page, I'd like it to extend all the way down to the bottom, if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然,你不能这样做。身体的高度取决于它所含的内容。
但是,一个简单的快速修复方法是将其添加到您的 CSS 中:
至于扩展,我已经编写了一个快速脚本(使用 jQuery),它似乎可以实现您正在寻找的功能。
请参阅:http://jsfiddle.net/UB7uT/(点击播放)
代码:
CSS:
JavaScript:
HTML:
You can't do this, naturally. The body only goes as high as the content it contains.
But, a simple quick fix would be adding this to your CSS:
As for extending, I've put together a quick script (using jQuery) that appears to do what you're looking for.
Please see: http://jsfiddle.net/UB7uT/ (click Play)
Code:
CSS:
JavaScript:
HTML: