[Resolved] Enable Smooth Scroll on buttons

Home Forums Support [Resolved] Enable Smooth Scroll on buttons

Home Forums Support Enable Smooth Scroll on buttons

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #851716
    Daniele

    Hi, how can I enable smooth scroll on buttons on my website. I can add classes to button, but “a” tag is inside the button so I cannot put smoot-scroll class directly on “a” tag.
    Example:

    
    <div class="wp-block-button is-style-squared smooth-scroll">
    <a href="#contact-form">CHIEDI INFORMAZIONI</a></div>
    
    #851780
    David
    Staff
    Customer Support

    Hi there,

    yes the button block is a bit of a pain for adding the wrapper to the button. There is this PHP snippet that applies the smooth-scroll to all tags:

    https://docs.generatepress.com/article/generate_smooth_scroll_elements/

    #852333
    Daniele

    THANKS

    #852344
    David
    Staff
    Customer Support

    You’re welcome

    #1173098
    Daniel

    Hello,
    I’m unable to get smooth-scroll to enable on a button in my hero.
    I’ve ticked the enable smooth-scroll box.
    My button looks like this:

    <p><a class="button smooth-scroll" href="#consult">Call to Action</a></p>

    And I’ve added and enabled the recommended PHP snippet:

    add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
      $elements[] = 'a[href*="#"]';
      
      return $elements;
    } );

    And still I get no smooth-scroll effect with my button. Any suggestions?

    #1173101
    Leo
    Staff
    Customer Support

    The link you provided in the original topic isn’t working for me.

    Can you confirm and maybe update that?

    Let me know ๐Ÿ™‚

    #1173104
    Daniel

    Hi Leo,
    I edited my original comment after posting it because of a typo. The link should say “#consult”. The link works on my website currently – just with no smooth-scroll effect. Does it work for you?

    #1173106
    Leo
    Staff
    Customer Support

    I just can’t get the site to load at all – it says This site can’t be reached

    Is that still the correct URL?

    #1173108
    Daniel

    Oh, my mistake. I am not the original poster – I just have a similar problem. My website is [removed]

    #1173111
    Leo
    Staff
    Customer Support

    Ahh Daniele and Daniel haha

    In that case can you please open a new topic?

    Thanks ๐Ÿ™‚

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.