Interview Prep
Interview questions, roadmaps and practice sets
Tutorials
Free tutorials on 30+ topics
Blog
Career guides, skills and interview tips
Free PDFs
Notes, cheat sheets and question banks
Certificates
Free skill tests and course certificates
Tools & Whiteboard
Free tools you can use right in the browser
Practice Tests
Mock tests, MCQs and quick Q&A
Free LMS
Learn on the Uncodemy LMS
Choose the best training program according to your career.
Improve the performance of your business with our innovative Industrial Training Program.
Read More →
Our instructor-led training classes are designed to make you an expert.
Read More →
Real-life case studies are a great way to demonstrate your practical knowledge.
Read More →
Explore blogs, latest technologies and industry updates with practical examples.
Read More →Browse all available training programs and choose the right one for your career.
Read More →Know more about who we are and what we stand for.
Discover our mission to equip individuals with essential IT skills and industry expertise.
Read More →
Free tutorials, interview questions, tools and calculators to help you learn.
Explore →Learn, practice and plan your career — bilkul free.
Book a free video counselling session and pick the right course for you.
Read More →Picture a long course page or blog post. The only "Book a demo" button sits at the top, and by the time a reader is convinced, three screens down, it has scrolled out of sight. A sticky call-to-action bar fixes that by keeping one action within reach as the reader scrolls. Done badly, it becomes one more thing covering the content. This tutorial builds a bar that appears only after the reader has scrolled past the top section, can be dismissed, works with keyboards and screen readers, respects phone notches, and reports clicks to analytics.

A sticky bar should carry one action, the one most readers of that page are likely to want next. On a course page that might be "Book a free demo"; on a product page, "Add to cart"; on a SaaS pricing page, "Start free trial". Two or three buttons in a bar compete with each other and with the page. Write the text before writing any code: a short statement of what the reader gets, and a verb on the button.
<div class="cta-bar" id="ctaBar" role="region" aria-label="Book a free demo">
<p class="cta-bar__text">Free 30-minute demo class this Saturday</p>
<a class="cta-bar__btn" href="/demo">Book a seat</a>
<button class="cta-bar__close" type="button" aria-label="Dismiss">×</button>
</div>
Place it just before the closing </body> tag. The role="region" with a label lets screen-reader users find it as a landmark. The close control is a real <button>, so it works with the keyboard without extra code.
.cta-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
padding: 10px 16px;
padding-bottom: calc(10px + env(safe-area-inset-bottom));
background: #14325c;
color: #fff;
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
transform: translateY(120%);
visibility: hidden;
transition: transform 0.3s ease, visibility 0.3s;
}
.cta-bar.is-visible {
transform: translateY(0);
visibility: visible;
}
.cta-bar__text { margin: 0; font-size: 15px; }
.cta-bar__btn {
background: #ffb703;
color: #14325c;
font-weight: 700;
padding: 10px 18px;
border-radius: 6px;
text-decoration: none;
white-space: nowrap;
}
.cta-bar__btn:focus-visible,
.cta-bar__close:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.cta-bar__close {
background: none;
border: 0;
color: #fff;
font-size: 24px;
line-height: 1;
min-width: 44px;
min-height: 44px;
cursor: pointer;
}
body.has-cta-bar { padding-bottom: 72px; }
@media (max-width: 480px) {
.cta-bar__text { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
.cta-bar { transition: none; }
}
A few choices here matter more than they look:
visibility: hidden while off-screen keeps the hidden button out of the tab order, so keyboard users do not land on something they cannot see.env(safe-area-inset-bottom) adds space above the home indicator on phones with gesture bars. For it to work on iOS, the page's viewport meta tag needs viewport-fit=cover.body.has-cta-bar adds bottom padding while the bar is visible, so the last lines of the page and the footer links are not hidden behind it.A bar that appears on page load just duplicates the button already in the hero. It is more useful once the hero has scrolled away. IntersectionObserver does this without listening to every scroll event:
const bar = document.getElementById("ctaBar");
const hero = document.querySelector(".hero");
let dismissed = false;
try { dismissed = sessionStorage.getItem("ctaDismissed") === "1"; } catch (e) {}
if (bar && hero && !dismissed) {
const io = new IntersectionObserver(([entry]) => {
const show = !entry.isIntersecting;
bar.classList.toggle("is-visible", show);
document.body.classList.toggle("has-cta-bar", show);
});
io.observe(hero);
bar.querySelector(".cta-bar__close").addEventListener("click", () => {
bar.classList.remove("is-visible");
document.body.classList.remove("has-cta-bar");
io.disconnect();
try { sessionStorage.setItem("ctaDismissed", "1"); } catch (e) {}
});
}
How it behaves: while any part of the hero is on screen, isIntersecting is true and the bar stays hidden. Once the hero scrolls fully out of view, the bar slides up. Scrolling back to the top hides it again. Clicking the close button hides it for the rest of the browser session; the try/catch blocks stop the script from failing in browsers that block storage. If the page has no element with the class hero, nothing happens, which is safer than a bar that appears everywhere.
If the site uses Google Analytics 4 through gtag.js, send an event when the button is clicked, so you can compare the bar against the other buttons on the page:
bar.querySelector(".cta-bar__btn").addEventListener("click", () => {
if (typeof gtag === "function") {
gtag("event", "cta_click", { cta_location: "sticky_bar" });
}
});
Register cta_location as a custom dimension in GA4 to see it in reports. The same idea, applied to links that leave your site, is covered in outbound link tracking, and a general GA4 setup is in tracking visitor behaviour with GA4.
On phones, a bottom bar sits where thumbs reach easily, and it does not push the site header around. On desktop, a slim top bar under the navigation is also common. For a top bar inside the normal page flow, position: sticky; top: 0; is simpler than fixed, but it only sticks within its parent element, so place it as a direct child of body or of a full-height wrapper.
A floating action button does a similar job for app-like interfaces; see adding floating action buttons. For the page around the bar, read landing pages with effective CTAs and using AI to improve landing pages.