javascript - 固定 div 但在页脚之前停止
问题描述
我需要固定 div(侧边栏),但必须在页脚之前停止。我写了一个代码,我已经写了一个星期了,我做不到->pastebin.com/q85pPBpc
解决方案
有一个非常短的 CSS 解决方案。它来自 Bootstrap 4。我想这就是你所需要的。
您的网站应具有以下结构:
<header></header>
<main>
<aside class="sticky-top"></aside>
<section></section>
<section></section>
<section></section>
</main>
<footer></footer>
简单的 CSS 会让你的侧边栏变得aside
粘稠,它会留在主要部分,不会进入页脚。
@supports ((position: -webkit-sticky) or (position: sticky)) {
.sticky-top {
position: -webkit-sticky;
position: sticky;
top: 0;
z-index: 1020;
}
}
推荐阅读
- angular - 如何在具有依赖关系的提供者中注册服务?
- pointers - 当我执行自己的程序时操作系统失败
- sumo - 如何为 SUMO(城市交通模拟)分配更多 CPU 和 RAM
- mongoose - 在猫鼬中合并两个不同的字段
- vba - Excel VBA - 从一张纸复制/粘贴范围到所有后续工作表
- c# - 发布请求为空(ASP.NET Core)
- c# - “ANTLR 入门”中的问题(无法创建 SpeakVisitor 类)
- python - GetControlPivot() 在 compute_gradients 期间返回 None
- vuejs2 - Vue组件名必须小写?
- javascript - 迭代和枚举数组,没有得到相同的结果