Problems with scrolling href to content on the same page in smaller resolutions

Asked

Viewed 34 times

0

My problem is this.

<a href="#saibamais" class="scroll-to">
  Saiba Mais
</a>

<div id="saibamais"></div>

$('a.scroll-to').on('click', function (e) {
   e.preventDefault();
$('html,body').animate({scrollTop: ($($(this).attr('href')).offset().top - 0)}, 600);});

On screens larger than 992 works normally, but changing the resolution from 992 down no longer works.

1 answer

0

Strange here on the site is working perfectly.

$('a.scroll-to').on('click', function() {
  $('html,body').animate({
     scrollTop: ($($(this).attr('href')).offset().top - 0)
  }, 600);
});
#saibamais{
  margin-top: 800px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#saibamais" class="scroll-to">
  Saiba Mais
</a>

<div id="saibamais">DIV SAIBAMAIS</div>

  • Works on normal desktop, but when I lower the screen it just doesn’t work anymore,

  • Which browser are you using? I tested it at 320 for 480 and worked normal.

  • I tested in firefox, Chrome, operates and nothing. I also tested directly by mobile and nothing. It works scroll, but the smoothness effect does not apply.

  • Strange, what seems to occur there with vc is that the function does not perform. Try to put an Alert in the function after the 600); Alert("testing"); to see if it runs.

  • I’ve done it, and it’s working.

  • Cara ta very strange this, if executed the Alert then the function is working. Soon the effect within the function should work.

  • I have the gift to make something right go wrong gasheuhiasegh PHP that says it.

  • This e. preventDefault() is not necessary.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.