Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Create a Sticky Social Media Bar using HTML and CSS
A sticky social media bar is a fixed navigation element that remains visible while users scroll through your website. It provides easy access to your social media profiles and helps increase engagement and followers. Using CSS, we can create an animated sticky bar that slides out on hover without affecting your website's performance.
Syntax
.social-container {
position: fixed;
right: -width;
transition: all 0.25s ease-in-out;
}
.social-item:hover {
margin-left: -slide-distance;
}
Example: Right-Side Sticky Social Bar
The following example creates a sticky social media bar on the right side with smooth hover animations
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: #f0f8f0;
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
.social-container {
position: fixed;
top: 50%;
right: -140px;
transform: translateY(-50%);
z-index: 1000;
}
.social-list {
list-style: none;
margin: 0;
padding: 0;
}
.social-item {
background-color: #34495e;
color: white;
height: 50px;
width: 180px;
margin-bottom: 2px;
display: flex;
align-items: center;
transition: all 0.3s ease-in-out;
cursor: pointer;
border-radius: 5px 0 0 5px;
}
.social-item:hover {
margin-left: -130px;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.social-item.linkedin { background-color: #0077b5; }
.social-item.youtube { background-color: #ff0000; }
.social-item.website { background-color: #2c3e50; }
.social-icon {
width: 40px;
height: 40px;
margin: 5px 10px;
border-radius: 50%;
background: white;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
color: #333;
}
.social-text {
flex: 1;
font-size: 14px;
font-weight: 500;
}
.social-text a {
color: white;
text-decoration: none;
}
.social-text a:hover {
text-decoration: underline;
}
.content {
max-width: 800px;
margin: 0 auto;
line-height: 1.6;
}
</style>
</head>
<body>
<div class="content">
<h1>Welcome to TutorialsPoint</h1>
<p>TutorialsPoint originated from the idea that there exists a class of readers who respond better to online content and prefer to learn new skills at their own pace from the comforts of their drawing rooms.</p>
<p>The journey commenced with a single tutorial on HTML in 2006 and elated by the response it generated, we worked our way to adding fresh tutorials to our repository which now proudly flaunts a wealth of tutorials and allied articles on topics ranging from programming languages to web designing to academics and much more.</p>
</div>
<div class="social-container">
<ul class="social-list">
<li class="social-item website">
<div class="social-icon">TP</div>
<div class="social-text">
<a href="https://www.tutorialspoint.com" target="_blank">Visit Our Website</a>
</div>
</li>
<li class="social-item linkedin">
<div class="social-icon">in</div>
<div class="social-text">
<a href="https://www.linkedin.com/company/tutorialspoint" target="_blank">LinkedIn Page</a>
</div>
</li>
<li class="social-item youtube">
<div class="social-icon">YT</div>
<div class="social-text">
<a href="https://www.youtube.com/channel/UCVLbzhxVTiTLiVKeGV7WEBg" target="_blank">YouTube Channel</a>
</div>
</li>
</ul>
</div>
</body>
</html>
A webpage with content and a sticky social media bar on the right side. The bar contains three social media buttons (Website, LinkedIn, YouTube) that slide out smoothly when hovered over, revealing the full text links.
Key Properties
| Property | Purpose |
|---|---|
position: fixed |
Keeps the bar in a fixed position during scrolling |
right: -140px |
Hides most of the bar off-screen initially |
transition |
Creates smooth sliding animation on hover |
z-index: 1000 |
Ensures the bar appears above other content |
Conclusion
A CSS-based sticky social media bar provides an elegant way to promote your social profiles without using heavy JavaScript plugins. The hover animation creates an engaging user experience while maintaining optimal website performance.
Advertisements
