html - 依赖页面滚动的 iframe 内的粘滞按钮
问题描述
如何在 iframe 中制作粘性按钮?我的意思是,当您使用 position:sticky 或 -web-sticky 时,该按钮在页面滚动时似乎没有检测到它。
我怎么做这个?
解决方案
当我想在 iframe 中使用粘性代码时,我总是使用Sticky-Kit使用这个我给出的链接点击这里
这很简单
只需在要卡在其父级中的元素上调用stick_in_parent。粘性元素“自下而上”,因此它们永远不会离开容器,不再担心粘性元素是否会意外覆盖您的页脚。
如果手动方式
<style>
div.sticky {
position: -webkit-sticky;
position: sticky;
top: 0;
background-color: yellow;
padding: 50px;
font-size: 20px;
}
</style>
<div class="sticky">I will stick</div>
推荐阅读
- c++ - 公共和私有域的 C++ 类重要性
- html - 如何编辑页面源以预加载系列中的下一个视频?
- python - 在 Python 中使用正则表达式在特定“空格”字符下方拆分句子
- httpclient - Ktor 服务器应用程序不断增加开放连接
- centos - MailKit 使用 LetsEncrypt SSL 证书获得 SslHandshakeException
- powershell - Powershell:Set-PnPListItem 删除分类值(空值)[SharePoint Online]
- javascript - API 获取问题
- sql - Pyspark SQL 用 NULL 替换元素
- nginx - 匹配位置后如何在nginx中重写url
- r - For循环结束而不显示输出