我知道这仅被标记为html / css,但是您不能仅使用css来做到这一点。最简单的方法是使用一些jQuery。
var fixmeTop = $('.fixme').offset().top; // get initial position of the element$(window).scroll(function() { // assign scroll event listener var currentScroll = $(window).scrollTop(); // get current position if (currentScroll >= fixmeTop) {// apply position: fixed if you $('.fixme').css({// scroll to that element or below it position: 'fixed', top: '0', left: '0' }); } else { // apply position: static $('.fixme').css({// if you scroll above it position: 'static' }); }});


