CSS components

CSS Sticky CTA Bar Generator

Design a slim announcement or call-to-action bar that stays fixed to the top or bottom of the screen and appears once a visitor has scrolled. Preview it live and copy the code.

Scroll inside the preview to see the bar slide in. Set the scroll distance to 0 to show it straight away.

Live preview

Runs entirely in your browser. Nothing is uploaded to any server.

Why add a sticky CTA bar

Always in reach

Your main action stays visible however far people scroll.

Not intrusive

It waits until the visitor is engaged and can be dismissed.

Tiny footprint

A few lines of CSS and JavaScript, no library.

How to create a sticky CTA bar

  1. Write the offerEnter a short message, button text and the link the button opens.
  2. Set behaviourChoose top or bottom, the scroll distance and whether people can close it.
  3. Copy the codePaste the HTML before the closing body tag and add the CSS and script.

Good practice for sticky bars

A sticky bar works best with one short message and one clear action. Keep it slim so it does not cover too much of the screen on phones, and always give visitors a way to dismiss it.

The bar starts off screen with transform and visibility, so it does not take up space or receive keyboard focus until it slides in. When dismissal is remembered, the choice is kept in sessionStorage and the bar stays hidden until the browser tab is closed.

One action

A single button converts better than several links.

Mobile first

On small screens the text and button stack and stay centred.

Accessible

A labelled region, a real link and a labelled close button.

Sticky CTA bar FAQ

Where do I paste the code?

Put the HTML just before the closing body tag, the CSS in your stylesheet and the script after the HTML.

Will the bar cover my footer?

A fixed bar sits above the page content. If it hides something important, add bottom padding to the body equal to the bar height.

How do I show the bar immediately?

Set the scroll distance to 0. The bar then starts visible and only hides when the visitor dismisses it.

How long is the dismissal remembered?

With the remember option on, it is stored in sessionStorage, so the bar returns in a new tab or browser session.

Is it bad for SEO?

A slim, dismissible bar is fine. Avoid full-screen overlays that block content, which search engines treat as intrusive interstitials.

Try other CSS component tools

More free tools from My Panda Toolbox.