2
2
2slide2014-07-18 22:32:36
JavaScript
2slide, 2014-07-18 22:32:36

How to make a dropdown menu like Yandex?

How to make the menu appear like Yandex?
Smooth appearance with slight fall out.
35021007323a4616928c0d28e18af4d8.jpg

I tried it and here's what's left.
There is no smooth appearance, a delay and an immediate appearance.

$("#more").click(function(){
  $('.more_menu').fadeIn(500).css('display', 'block');
 });

Thank you.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
Y
Yuri Lobanov, 2014-07-19
@2slide

$('.more').click(function(){
  var menu = $('.menu');
  if (menu.css('display') == 'none') {
    menu.fadeIn(300);
  }
  else {
    menu.fadeOut(100);
  }
});

Example:
codepen.io/iiil/pen/HEDeI

A
Andrey Morozov, 2014-07-18
@LuckyTrue

You can't animate from display: none to display: block . Try it with opacity and element position .

S
Sergei Chukhan, 2014-07-18
@street

It's easy enough to write:

$("#more").click(function(){
  $('.more_menu').fadeIn('fast');
});

The ".more_menu" element must initially be display:none;

L
lnked, 2014-07-19
@lnked

$("#more").click(function(){
  $('.more_menu').fadeIn(500).css('display', 'block');
 });

in your example, the fade begins and before it has time to work out for half a second, the display block is immediately assigned to the element so
that it doesn’t happen, do this:
$("#more").click(function(){
  $('.more_menu').fadeIn(500, function(){
             $(this).css('display', 'block');
        });
 });

that is, the display block will be written only after the animation has passed.

K
Khabib Omarov, 2014-08-25
@temp-market

var moremenu = $('.more_menu');
moremenu.hide();
$("#more").click(function(){
  $('.more_menu').fadeIn(500);
 });

And that's it, make more_menu variable and hide it with hide(); , then do it via fadeIn(interval). And all you don't need to set css after fadeIn

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question