javascript - 带有位置的标题:sticky 在收缩时在 chrome 中闪烁
问题描述
一旦达到滚动高度,我就有一个导航元素,位于其他内容下方。fixed
这是通过所有浏览器实现的position:sticky
并且在所有浏览器中都可以正常工作。但我也想在它修复后立即缩小它。
https://codepen.io/arichter83/pen/xMLyOJ
如果在Chrome(71.0.3578.98 64 位 Mac)上缓慢滚动,此标题会闪烁,因为如果元素正在缩小,则页面的window.scrollY会缩小,这会使元素再次变大......来回。(使用“开始”查看行为)
有什么解决方法吗?
- 以固定高度包裹:这将阻止下面的内容向上移动,这是我想要的。
解决方案
向您的 header.minified ID 添加位置属性似乎已经停止闪烁。
#header.minified {
font-size: 24px;
line-height: 48px;
height: 48px;
background: #efc47D;
text-align: left;
padding-left: 20px;
position: fixed;
}
推荐阅读
- javascript - Javascript数组相等控制和改变值
- angular - 当按钮以角度禁用时,谷歌浏览器中不显示任何工具提示
- javascript - 返回预期的输出但仍然错误?
- php - 如何将http url重定向到https url?
- javascript - 父 div 未使用 parent().show() 方法显示
- javascript - 未捕获的类型错误:$(...).makeRed 不是函数
- testing - 查询测试的试剂/打嗝标记
- java - 为 cmake 执行外部库(Android Studio)
- redis - 使用 Capistrano 部署到 DigitalOcean 时出现 Redis 错误
- boost - 找不到 Boost - python3 组件丢失