jquery - How to make your div stick to the page even when resolution of the window changes -
i want div scroll down scroll window,its happening when change resolution of window position shifts
this code
$(document).ready(function() { var stickynavtop = $('#sticker').offset().top; var stickynav = function() { var scrolltop = $(window).scrolltop(); if (scrolltop > stickynavtop) { $('#sticker').addclass('effect'); } else { $('#sticker').removeclass('effect'); } }; });
// in css file
.effect { position: fixed; width: 100%; left: 783px; top: 0px; }
basically screen resolution independent thing position fixed
if have
<div class="asd"></div>
and want fix div css :
.asd{position:fixed; top:0;}
in case may have forgotten . in css. "." defines class
.effect { position: fixed; width: 100%; left: 783px; top: 0px; }
Comments
Post a Comment