框架集的纯 CSS 模拟
我已经搜索了1个多小时没有成功。有没有一种纯 CSS 的方式来模拟框架集?我的意思是,真的模仿它。我发现了一些有趣的东西,您将有固定的顶部和底部块,但内容的滚动条是常规的浏览器主体滚动条。我需要的是一个仅用于内容块的滚动条,就像框架集所做的那样。
我可以通过将 Overflow: auto 分配给我的内容区域 div 并设置固定高度来使其工作。但问题是我不知道客户端浏览器窗口大小而不使用 javascript。我不想为此使用 javascript。我也不能使用百分比来表示高度,因为我的顶部块具有固定的高度。下面的块应该根据浏览器窗口的高度扩展或缩小。任何帮助表示赞赏。谢谢你!
I have been searching for more than 1 hour with no success. Is there a pure CSS way of emulating a frameset? I mean, really emulating it. I have found some interesting stuff where you will have fixed top and bottom blocks, but the scroll bar for the content is the regular browser body scrollbar. What I need is a scrollbar only for the content block, as a frameset would do.
I can make it work by assigning overflow: auto to my content area div and setting a fixed height. But the problem is I don't know the client browser window size without using javascript. And I don't want to use javascript for this. I also canot use percents for the heights as my top block has a fixed height. The lower block is the one that should expand or shrink depending on the browser window height. Any help appreciated. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
像这样的事情怎么样?
HTML
CSS
How about something like this?
HTML
CSS
Makro 的答案很接近,但效果不佳。内容与标题重叠。
就这一点而言,您希望将
position:fixed;
用于标题,而不是内容。这也使得包装器变得多余。这是一个基本的启动示例,您可以复制“粘贴”然后运行它。The answer of Makro is close, but doesn't work well. The content overlaps the header.
To the point, you'd like to use
position: fixed;
for your header, not for your content. This also makes the wrapper superfluous. Here's a basic kickoff example, you can copy'n'paste'n'run it.不,我认为你必须使用 javascript 来获取窗口大小,除非你将顶部块设置为固定的 % 大小,例如使顶部块为 10%,底部块为 90%。
No. I think you will have to use javascript to get the window size for this, unless you set the top block to a fixed % size, e.g. make the top block 10% and the bottom 90%.