Halloween Sale 15% off Ends in See the plans
HTML

Floating Call-to-Action Button After Scrolling

Shows a floating button in the bottom corner once visitors have scrolled past the first screen, for "Book a call", "Get a quote" or "Shop now" links.

Don’t have WPIDE yet? Install it on your site

Code

<a class="wpide-floating-cta" href="/contact/" hidden>Get a free quote</a>
<style>
.wpide-floating-cta{position:fixed;right:20px;bottom:20px;z-index:9980;padding:14px 22px;border-radius:999px;background:#111827;color:#fff!important;font-weight:600;text-decoration:none;box-shadow:0 8px 24px rgba(0,0,0,.25);opacity:0;transform:translateY(16px);transition:opacity .25s ease,transform .25s ease;}
.wpide-floating-cta.is-visible{opacity:1;transform:none;}
.wpide-floating-cta:focus-visible{outline:3px solid #2271b1;outline-offset:3px;}
@media (prefers-reduced-motion:reduce){.wpide-floating-cta{transition:none;}}
@media (max-width:600px){.wpide-floating-cta{left:16px;right:16px;bottom:16px;text-align:center;}}
</style>
<script>
(function () {
    var cta = document.querySelector('.wpide-floating-cta');
    if (!cta || cta.pathname === window.location.pathname) { return; }
    cta.hidden = false;
    var update = function () { cta.classList.toggle('is-visible', window.pageYOffset > window.innerHeight * 0.8); };
    window.addEventListener('scroll', update, { passive: true });
    update();
})();
</script>

Notes

Edit the link text and URL in the HTML. The button hides on the page it links to.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.