Как сделать, чтобы у длинного плавающего aside при прокрутке клеился низом к экрану?
привет! Ребята, нужно сделать так, чтобы при прокрутке экрана в низ, длинный плавающий aside клеился низом к экрану. Но если он не длиннее высоты экрана, то чтобы так и клеился к вверху. ( Идея отсюда , нужно чтобы двигался aside как на этом сайте )
Вот мой сайт http://wikihsk.ru/publ/ Переделать нужно этот код $stick = $('aside'); $foot = $('footer'); margin = 0; offtop = $stick.offset().top - margin; offbtm = $foot.offset().top - ( margin*2 + $stick.height() ); $(window).scroll(function () { scrtop = $(window).scrollTop(); if (scrtop > offtop && $stick.hasClass('aside1')) { $stick.removeClass('aside1').addClass('fixed').css('top', margin); } if (offtop > scrtop && $stick.hasClass('fixed')) { $stick.removeClass('fixed').addClass('aside1').css('top', 'auto'); } if (scrtop > offbtm && $stick.hasClass('fixed')) { $stick.removeClass('fixed').addClass('bottom').css('top', offbtm+margin); } if (offbtm > scrtop && $stick.hasClass('bottom')) { $stick.removeClass('bottom').addClass('fixed').css('top', margin); } }); aside.fixed {position: fixed;} aside {position: absolute; display: block; margin-left: 650px; } article {position: relative;} footer { position: relative; clear: both; height: 300px; } |
Часовой пояс GMT +3, время: 00:10. |