0
How do I make a menu like that of Wordpress that is vertical, fixed and has a scrolling of its own that is limited to its ends:
In wordpress the element div gets a "position:Fixed" when arriving at the end and at the beginning of the menu to stop interacting with the scrolling, and when scrolling it defide "position:Absolute" and "top:Numeroquenaoconsigofazer".
I was trying to do with javascript but it’s impossible:
$(window).scroll(function(event) {
element = $('#sidebar_main');
p_current = $(this).scrollTop();
h_nav = element.height();
h_screen = $(window).height();
if(h_nav > h_screen){//se maior que a tela
h = (h_nav - h_screen)+40;
if(p_current > last_scroll){//se desce
if(p_current>=h){//se já chegou no fim
element.css({
'position': 'fixed',
'bottom': '0',
'top': 'auto'
});
}else{
if(element.css('top') == 'auto'){
element.css('top', 0);
}
element.css({
'top': '+=1px',
'position': 'absolute',
'bottom': 'auto'
});
}
}else{//se sobe
if(p_current<=0){//se já chegou no começo
element.css({
'top': '0',
'bottom': 'auto'
});
}else{
//if(element.offset().top <= h || element.css('top') == 'auto'){
if(element.css('top') == 'auto'){
element.css('top', element.offset().top);
}
element.css({
'top': '-=1px',
'position': 'absolute',
'bottom': 'auto'
});
}
//}
}
last_scroll = p_current;
}
});
Avoid links as a response!
– Igor Mello
Ok ! Anyway, it is a tip to be taken into consideration...
– Ikaro Sales
It’s still the same. Your answer doesn’t answer the question, it’s directing the "real" solution to the link anyway. In order for the answer to be independent of the link, you can add an example of a solution in code in the body of the answer, so the link will only serve as a reference, instead of being the answer
– user28595