div flotante

$(document).ready(function() { var docked = false; var menu = $('.menu'); var init = menu.offset().top; $(window).scroll(function() { if (!docked && (menu.offset().top - $("body").scrollTop() < 0)) { menu.css({ position : "fixed", marginTop: '0', width: $('.menu-contenedor').width()+"px", top: 20, }); docked = true; } else if(docked && $("body").scrollTop() <= init) { menu.css({ position : "relative", marginTop: '0px', width: '100%', // top: init + 'px', top: 0 }); docked = false; } }); });

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.