Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JS:
- var s = $("#sticker");
- var pos = s.position();
- $(window).scroll(function(){
- var windowpos = $(window).scrollTop();
- if(windowpos >= pos.top){
- s.addClass("stick");
- }else{
- s.removeClass("stick");
- }
- });
- CSS:
- #sticker{
- width: 100%;
- }
- .stick{
- position: fixed;
- top: 0px;
- z-index: 999999999;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement