Whether you’re adding a “Chat Now”, “Scroll to Top”, or “Buy Now” button, placing a fixed button on the bottom right of your web page ensures high visibility and accessibility. It remains in place even as users scroll, boosting engagement and conversions. This guide will walk you through adding a stylish, functional fixed button using pure HTML and CSS—no JavaScript needed!
🛠️ Step-by-Step Guide to Add a Fixed Button
We’ll be using position: fixed;
in CSS to make the button stick to the bottom-right corner of the screen.
✅ Example Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Fixed Button Example</title>
<style>
.fixed-button {
position: fixed;
bottom: 20px;
right: 20px;
background-color: #007BFF;
color: white;
padding: 12px 20px;
border: none;
border-radius: 8px;
cursor: pointer;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
font-size: 16px;
z-index: 1000;
transition: background-color 0.3s ease;
}
.fixed-button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<button class="fixed-button" onclick="window.scrollTo({top: 0, behavior: 'smooth'});">
↑ Top
</button>
</body>
</html>
💡 How This Works:
position: fixed;
: Makes the button stay in place even when scrolling.bottom: 20px; right: 20px;
: Places the button 20px from the bottom-right edge.- Styling: Rounded corners, hover effects, and shadows give it a clean, modern look.
- Functionality: The
onclick
scrolls the page to the top (you can customize the action).
🎨 Customization Tips
You can easily tweak the button to fit your brand:
- Change the background color:
background-color: #28a745;
for green. - Use icons inside the button with FontAwesome or SVG.
- Link to a chat box or contact form instead of scrolling to top.
<a href="#contact" class="fixed-button">💬 Chat</a>
Use <a>
tags instead of <button>
when linking to other sections.
📱 Mobile Friendly?
Absolutely! You can make it even more responsive with media queries:
@media (max-width: 600px) {
.fixed-button {
bottom: 10px;
right: 10px;
padding: 10px 16px;
font-size: 14px;
}
}
⚠️ Common Mistakes to Avoid
- Not using
z-index
: Your button may get hidden behind other elements. - Using
position: absolute
instead offixed
: It won’t stay visible on scroll. - No hover effect: Without feedback, users may ignore it.
🧠 Final Thoughts
A fixed button in the bottom-right corner is one of the easiest and most effective ways to drive interaction and improve usability on your website. Whether you’re linking to a form, chat, or just helping users scroll up—this small UX tweak can have a big impact.
Try this code on your site and let us know how you customized it!
Need help integrating it with WordPress or your theme? Drop a comment below—we’re here to help. 👇