M
M
Mariana Marianova2020-05-06 19:35:03
JavaScript
Mariana Marianova, 2020-05-06 19:35:03

How to make smooth scroll to bootstrap tab?

How to make smooth scroll to bootstrap tab when clicking on a link? For some reason, the smooth scrolling to the open taboo itself does not occur
Here I posted the code https://codepen.io/marishik92/pen/NWGyjqw. Here you click on the link "All characteristics"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arseny, 2020-05-07
@idmarishik

Bootstrap is tied to jQuery → which can do this:

$(".clickelem").click(function (){
    $('html, body').animate({
        scrollTop: $("#tabname").offset().top
    }, 2000);
});

Personally, I like VanillaJS more, but not all browsers eat it:
window.scrollTo({
    top: [elem offset top],
    behavior: "smooth"
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question