-1

My website is this : https://ayusg183.pythonanywhere.com . but I want it to be that if you press a certain button, like I can create a button called gallery and when you press it, it scrolls down the page. I can make a button, but I can't make the button scroll down. I am using html to code, not flask.

Ayush Gudipati
  • 57
  • 1
  • 1
  • 10

1 Answers1

1

CSS:

.navbar-link {
display: inline-block;
margin-bottom: 5000px; /* for demo purpose only */
}

HTML:

    <a href="#navbarGallery" class="navbar-link">Go to Gallery</a> /* place this in navbar */

<section id="navbarGallery">
    <div class="container-fluid">
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
</section>

jQuery:

$(document).ready(function(){
$("a[href='#navbarGallery']").on("click", function (e) {
        $("html, body").animate({
            scrollTop: $($(this).attr("href")).offset().top /* scroll to the matching id */
        }, 1000); /* here 1000 in ms */
 });
});
Rafee Shaik
  • 681
  • 4
  • 10