I have a menu that goes down along with the scroll. I used Jquery to add css attributes for this to occur. I do not want this to happen when the site has less than 768px of width. So let it be stopped
Media queries did not help me resolve because these attributes were added regardless of resolution. Then I tried the following:
$(window).scroll(function() {
if ($(window).width() < 760)
{
$('#menu').css({'position' : 'absolute'});
}
});
Or this
$(function() {
if ( $(window).width() < 760) {
$('#menu').css({'position' : 'relative'});
}
});
But it did not roll in both cases. I'm new to Jquery. How to complement this code to make it work? Am I going the right way?
This is the code that makes my scroll menu
$(function() {
$(window).scroll(function()
{
var topo = $('#topo').height(); // altura do topo
var rodape = $('#rodape').height(); // altura do rodape
var scrollTop = $(window).scrollTop(); // qto foi rolado a barra
var tamPagina = $(document).height(); // altura da p?gina
if(scrollTop > topo){
$('#menu').css({'position' : 'fixed', 'top' : '0'});
}else{
$('#menu').css({'position' : 'relative', 'margin-top' : 0});
}
});
});