gpt4 book ai didi

html - 框架集的纯 CSS 仿真

转载 作者:太空狗 更新时间:2023-10-29 14:21:38 26 4
gpt4 key购买 nike

我已经搜索了 1 个多小时没有成功。是否有模拟框架集的纯 CSS 方式?我的意思是,真的在模仿它。我发现了一些有趣的东西,您将在其中固定顶部和底部 block ,但内容的滚动条是常规的浏览器主体滚动条。我需要的是仅用于内容 block 的滚动条,就像框架集一样。

我可以通过将 overflow: auto 分配给我的内容区域 div 并设置固定高度来使其工作。但问题是如果不使用 javascript,我不知道客户端浏览器窗口的大小。我不想为此使用 javascript。我也不能使用百分比表示高度,因为我的顶部 block 具有固定高度。下面的 block 是应该根据浏览器窗口高度扩展或收缩的 block 。任何帮助表示赞赏。谢谢!

最佳答案

这样的事情怎么样?

HTML

<div id="header">
<img src="logo.gif" alt="logo" />
<h1 class="tagline">Oh em gee</h1>
</div>
<div id="content">
<div id="content-offset">
<p>This will be 100% of the screen height, BUT the content offset will have a top pixel margin which allows for your header. Set this to the pixel value of your header height.</p>
</div>
</div>

CSS

body, html {
margin: 0; padding: 0;
height: 100%;
}
#header {
height: 120px;
position: fixed;
top: 0;
background: red;
width: 100%;
}

#content {
height: 100%;
position: absolute;
top: 0;
}
#content-offset {
margin-top: 120px;
background: aqua;
height: 100%;
width: 100%;
position: fixed;
overflow: auto;
}

关于html - 框架集的纯 CSS 仿真,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3433129/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com