-3

Need to make my button scroll to the buttom of the site. this is my button:

 <a href="#" class="button-bord">Read more <br /><p class="glyphico glyphicon-chevron-down arrow-down"></p></a>

How can i make it so that i scrolls to the buttom of the site? Any suggestions :)

Maximillian Laumeister
  • 19,884
  • 8
  • 59
  • 78

2 Answers2

2

The supposed duplicate question linked in the comments asks for JavaScript/jQuery answers, but from your tags it looks like you're looking for a pure HTML/CSS solution (note: question tags have since been edited). You can do it using an a tag without any JS.

Just put an element with a certain id at the very bottom of your markup (in this case it's another anchor with the id bottom), then you can use the original a tag to link to that element within the page. If the new element is at the bottom of the page, then you're linking to the bottom of the page.

The div with class spacer (and a height of 800px) is used in this example to push some of the content down on the page, so that the document has a scrollbar. That way you can see the page scroll after you click the internal link.

Live Demo:

.spacer {
    height: 800px;
}
<a href="#bottom">Click to go to bottom</a>
<div class="spacer"></div>
Bottom of the page
<a id="bottom"></a>
Maximillian Laumeister
  • 19,884
  • 8
  • 59
  • 78
1

Include the jQuery library:

<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" />
</head>

Here is in the script:

<script>
  $('.button-bord').on('click', function() {
    $('html, body').animate({scrollTop:$(document).height()}, 'slow');
    return false;
  });
</script>
Norbert
  • 2,741
  • 8
  • 56
  • 111
Esko
  • 683
  • 9
  • 23
  • Excatly thanks :) Didn't need the head since i'm workinng in mvc :) But thanks alot worked, and nnow i can keep going :) – Rasmus Vejby Oct 02 '15 at 20:32
  • Do you know if it shall scroll to the buttom of my image: What would i then have to do? :) – Rasmus Vejby Oct 02 '15 at 20:40
  • To scroll to the bottom of the image, replace `document` with something referencing to the image. If it's the only image with class `img-responsive` then replace `document` with `'.image-responsive'`. – Esko Oct 02 '15 at 21:21
  • I see the idea but i won't scroll down, it just saying syntax error :) – Rasmus Vejby Oct 03 '15 at 08:02