Hello.
There is a fixed block at the bottom of the screen.
position:fixed; bottom:0; width:100%; z-index:9999; How to make it stick to the top of the footer when the page is scrolled to the footer?
Hello.
There is a fixed block at the bottom of the screen.
position:fixed; bottom:0; width:100%; z-index:9999; How to make it stick to the top of the footer when the page is scrolled to the footer?
position: sticky + filament group Fixed-sticky polyfill .
* { margin: 0; padding: 0; box-sizing: border-box; } .container { display: flex; } article { width: 70%; height: 800px; background: #000; } aside { width: 25%; background: yellow; position: relative; } .aside__sticky { position: sticky; height: 200px; top: 0; border: 3px solid red; background: #ccc; } footer { height: 300px; background: #999; } <div class="container"> <article></article> <aside> <div class="aside__sticky"></div> </aside> </div> <footer></footer> Something like that, or did you mean something else?
$(window).on('scroll.a', function() { var a = $('#a').position().top-$(window).height() if($(this).scrollTop()>=a){ $('.fixed').css({'position':'relative','bottom':'85px'}) $(window).off('scroll.a'); } }) .fixed{position:fixed; bottom:0; width:100%; z-index:9999; background-color: #ddd;} <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div>a</div><div><div id="a">m</div></div><div>a</div><div>a</div><div>a</div><div class="fixed">a</div> Source: https://ru.stackoverflow.com/questions/627999/
All Articles