When clicking a button, how to make the screen slide down

Asked

Viewed 4,227 times

0

I have an area with prices, and I have a button right next to "have more details", I want that when you click this button, the screen slide down the page that is where I have the "contact" section. I wish I knew how to make this "slip"

3 answers

0

Do not use the attribute name, that’s deprecated in the latest version of HTML and J. Guilherme’s answer may not work in newer browsers. Use id:

<div id='meuelemento'> <!-- ... --> </div>

And in the <a>:

<a href='#meuelemento'> <!-- ... --> </a>

0

If you want the screen to slide with animation, you can use the jquery Animate.

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

0


Use anchovies:

put it on the button:

<a href="#anchor">botão</a>

and where you want to go you put:

<div id="anchor"></div>

Browser other questions tagged

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