IE兼容position: sticky
库:https://github.com/wilddeer/stickyfill
代码语言:javascript复制// install
npm install stickyfilljs --save
or
yarn add stickyfilljs
or
<script src="path/to/stickyfill.min.js"></script>
代码语言:javascript复制// html
<div class="sticky">
...
</div>
代码语言:javascript复制// css
.sticky {
position: -webkit-sticky;
position: sticky;
top: 0;
}
// clearfix
.sticky:before,
.sticky:after {
content: '';
display: table;
}
代码语言:javascript复制import Stickyfill from "yarn add stickyfilljs";
// js usage
var elements = document.querySelectorAll('.sticky');
Stickyfill.add(elements);
// jq usage
var elements = $('.sticky');
Stickyfill.add(elements);