html - 框架集的纯 CSS 仿真

标签 html css dom xhtml frameset

我已经搜索了 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/

相关文章:

javascript - 在 XUL 中,我如何知道浏览器标签已完成加载?

java - 如果属性具有特定值,则删除 XML 节点

html - Gatsby 链接无法正确呈现

javascript - EditableGrid - 通过 jQuery 获取 <td> 的新值

javascript - Twitter/Typehead 建议内联显示

javascript - 使用 Bootstrap 3.1 在 IE9 中无法加载 CSS 压缩

javascript - 具有ID的DOM树元素是否会成为全局变量?

php - 我可以在不使用提交按钮的情况下发布数据吗

HTML 内容不在窄屏幕上居中

html - 即使在 HTML 字符串中提供完全限定的 URL 后也无法应用外部 CSS