V
V
Vitya Podpriklopolny2018-02-15 12:08:10
css
Vitya Podpriklopolny, 2018-02-15 12:08:10

How to implement similar in css/html/js?

5a854c7d2f03c531101886.png
Such a button is called something like an anchor, right?
did like this (without "a")

<div class="scroll "><i class="fa fa-arrow-down"></i></div>

prescribed styles, well, it’s clear
now how best to implement it so that when you click on a div, the page smoothly leaves for a section below?
how to write it in js?
I can’t find it on the Internet, it doesn’t knock out what I need like
http://http://htmlbook.ru/samhtml/yakorya
, but I have a block with an icon. MM?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex-1917, 2018-02-15
@megamage

There will be no smooth scrolling on anchors, as you say , so only js
Longhorn gave garbage, this is code for one browser, somewhere it will not work either in mozilla or in chrome or in opera. even on Habré rubbed.
It’s not necessary body.animate, but it’s necessary ('body,html').animate(exaggerated)
Here is from the working draft, here you scroll to the block with id="map", and the second link scrolls to the block with id="box_middle" if you don't want links, then make data attributes and go ahead:

<a href="#map" class="go_bottom go_link"></a>
<a href="#box_middle" class="go_middle go_link"></a>

jQuery('a.go_link').click(function(event) {
  event.preventDefault();
  var id  = jQuery(this).attr('href');
  if (jQuery(id).length != 0) {
    var top = jQuery(id).offset().top;
    top = top-96;
    jQuery('body,html').animate({scrollTop: top}, 1500);
  }
});

D
Dima, 2018-02-15
Dolgoter @DDolgy

here

P
profesor08, 2018-02-15
@profesor08

https://greensock.com/
https://greensock.com/ScrollToPlugin

$(".scroll").on("click", function() {
  TweenLite.to(window, 2, {
    scrollTo: window.innerHeight 
  });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question