html - html header 中的 Position Sticky 不起作用,我怎样才能使它起作用?
问题描述
我正在尝试使标题变粘我花了半个小时调试它,有人可以帮我解决吗?
我确定我错过了一些东西,但我无法弄清楚。
这是密码笔。
https://codepen.io/hashir621/full/gORELOo
HTML:
<div class="parent_header">
<div class="header">
</div>
</div>
<div class="test_height">
</div>
CSS
.parent_header {
height: 100px;
}
.header {
background-color: green;
width: 100vw;
height: 100px;
position: sticky;
top: 0;
}
.test_height {
background-color: red;
width: 100vw;
height: 1000px;
}
解决方案
找到下面的代码片段
.header {
background-color: green;
width: 100vw;
height: 100px;
position: sticky;
position: -webkit-sticky;
top: 0;
}
.test_height {
background-color: red;
width: 100vw;
height: 1000px;
}
<div class="header">
</div>
<div class="test_height">
</div>
推荐阅读
- sql - 基于大小写的 SQL 过滤器
- google-app-engine - 在 Google Cloud Build 过程中连接到数据库的问题
- java - AspectJ 不适用于实现 AsyncUncaughtExceptionHandler 的类
- java - 使用 lambda 表达式和正则表达式 java 返回具有文件大小的映射
- javascript - Javascript:indexOf() 和 substr() 未返回日期字符串的预期结果
- python - 在 Jupyter 笔记本中使用 PIL 库运行 2 段等效的 Python 3.7.6 代码,但得到不同的结果
- time-complexity - 时间复杂度:我们如何找到 O(n^3)?
- python - 由于依赖关系,无法在 Centos 7 中卸载 numpy
- python - 从列表列表创建数据框:每条记录的列数据重复
- sql - 将 SP 输出保存到 powershell 中的变量中