Home>Support>Make Sub Menus Slide Down Gently

Make Sub Menus Slide Down Gently

Hi Greg & gang,
I am wondering what css code to use to make the sub menu items under the main nav items roll down gently as shown in this tutorial: http://candpgeneration.com/toys/CSS3-dropdown-tut.php
I know it’s the transition property and I have played around a bit, but I can’t seem to make it happen.
Thanks in advance!

URL: http://www.barbpetersonwebdesign.com/art

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 8 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    Hi Barb

    The menu is controlled by JavaScript, not CSS. However, you can install a plugin called Header and Footer Scripts, I’m using the one by WPBeginner. Then, in the header field provided by the plugin, insert:

    <script>
    jQuery(function($){
    
        // The menu hover effects
        $('#masthead')
            .on('mouseenter', '.main-navigation ul li', function(){
                var $$ = $(this);
                var $ul = $$.find('> ul');
                $ul.css({
                    'display' : 'block',
                    'opacity' : 0
                }).clearQueue().animate({opacity: 1}, 900);
                $ul.data('final-opacity', 1);
            } )
            .on('mouseleave', '.main-navigation ul li', function(){
                var $$ = $(this);
                var $ul = $$.find('> ul');
                $ul.clearQueue().animate( {opacity: 0}, 900, function(){
                    if($ul.data('final-opacity') === 0) {
                        $ul.css('display', 'none');
                    }
                });
                $ul.data('final-opacity', 0);
            } );
    
    });
    </script>
    

    See my two 900 values. Those are 250 by default. You can adjust to slow the transition down further. You can reduce to speed it up.

  2. 8 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    Plugin I used: https://wordpress.org/plugins/insert-headers-and-footers/

  3. 8 years, 10 months ago Barb Peterson

    Thanks for the code, Andrew, and for taking the time to research a rather esoteric request!
    However, it must be conflicting with some of the existing code in the Vantage’s menu javascript. Take a look at how things roll out now that I’ve added your script (www.barbpetersonwebdesign/art). I tried adjusting the 900 upward and downward, but it never achieved the smooth rolldown as in the tutorial I referenced above.

    Not the end of the world if this can’t be achieved but it is a really nice smooth effect and adds a calmness to the navigation process…
    Thanks in advance,
    ~Barb

  4. 8 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    I can take a quick look if you’d like.

  5. 8 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    Hi Barb

    Would it be possible for you to create a temporary admin account for us so we can log in and take a look? You can create the account with the following email address:

    [email protected]

    Just navigate to Users > Add New in your WordPress admin. Enter siteorigin for the username and [email protected] for the email address. Make sure you’ve selected Administrator for the role and enabled the “Send Password” field so we receive the details.

    Once we’re finished taking a look, you can delete this account. We’ll let you know when to do that.

  6. 8 years, 10 months ago Barb Peterson

    Thanks, Andrew!

    The password should be arriving in your inbox any moment! Your help is much appreciated!!!

  7. 8 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    Hi Barb

    Sorry, doesn’t seem like it arrived. Please, could you send using the Private Reply option bottom right. Thanks :)

  8. 8 years, 10 months ago Private Message - Barb Peterson

    This is a private message.

  9. 8 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    I can see the problem, the transition is happening twice, the second transition is the delayed one. I can’t figure out why I’m not getting the same result on my local demo.

  10. 8 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    Fixed :) Check now.

  11. 8 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    The problem was Appearance > Theme Settings > General > Enqueue JavaScript in Footer. For this application we that setting disabled. We need the scripts in the default location, in the document head.

  12. 8 years, 10 months ago Barb Peterson

    Andrew! You’re a magician! Thanks so much for figuring this out!

    Do you think it makes an appreciable site performance difference with all of the JavaScript NOT being enqueued in the the footer?

    In other words, now that you have spent all that time helping me with this (and I truly appreciate the time spent), is the effect worth any decrement in site speed?

  13. 8 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    There will be a small difference. On normal DSL connections it probably isn’t noticeable. Up to you.

  14. 8 years, 10 months ago Barb Peterson

    Thanks again for your prompt help!

  15. 8 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    For sure :)

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More