In this article, you will learn how to create social share buttons using HTML and CSS to make your website more shareable. Following up on my previous blog post, I will be focusing on animating a share button and incorporating social media icons.Â
Share button with both social share is eye-catching and attractive share button not only encourages users to share the content with others but also adds value to the overall design of the website. In today’s world, where visual content plays a critical role in creating an impact, adding animations to share buttons can make them more appealing and effective.Â
How To Create Social Share are Button Using HTML CSS
Create a Folder: Start by creating a folder for your project. You can name it anything you like. Inside this folder, you’ll need to create the following files:
- index.html (for the structure of your Social Share Button)
- style.css (for styling the Social Share Button)
Create the HTML File:
- Name your HTML file index.html.
Create the CSS File:
- Name your CSS file style.css.
Step 1: Create HTML Structure
To start, we need to create the HTML structure for our social share button. We will use a <div> element with a class of “share-btn” to wrap our button.
Step 2: Design the Button with CSS
Second, we will use CSS to style our social share button.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #faf5ffcb;
}
.share-container {
position: relative;
}
.share-btn {
width: 100px;
height: 40px;
background: linear-gradient(45deg, #ff7e5f, #feb47b);
border-radius: 20px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
transition: all 0.5s ease;
font-size: 16px;
color: white;
}
.social-icons {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
gap: 15px;
visibility: hidden;
opacity: 0;
transition: all 0.5s ease;
}
.social {
width: 120px;
height: 40px;
background: linear-gradient(45deg, #4776e6, #8e54e9); /* Gradient color */
border-radius: 20px;
display: flex;
justify-content: center;
align-items: center;
color: white;
font-size: 14px;
font-weight: 500;
text-decoration: none;
cursor: pointer;
transition: transform 0.3s ease;
padding: 0 10px;
}
.social i {
margin-right: 8px;
}
.social:hover {
transform: scale(1.1); /* Scale up on hover */
}
.social-icons span {
display: inline-block;
}
.share-container:hover .social-icons {
visibility: visible;
opacity: 1;
transform: translate(-50%, -120%);
}
.share-container:hover .share-btn {
transform: scale(0);
}
@media (max-width: 768px) {
.social {
width: 100px;
font-size: 12px;
}
.share-btn {
width: 80px;
height: 35px;
font-size: 14px;
}
}
We have seen how to create social share buttons using HTML and CSS. With a few lines of code, we have created a beautiful and interactive share button that will make your website more shareable. Feel free to experiment with different styles and effects to make it unique to your website. With these social share buttons, you can encourage your visitors to share your content and increase your online presence.
If the code doesn’t work or if you run into any issues, please leave a comment below or reach out to us through the contact page.
- Like
- Digg
- Del
- Tumblr
- VKontakte
- ‎
- Buffer
- Love This
- Odnoklassniki
- ‎
- Meneame
- Blogger
- Amazon
- Yahoo Mail
- Gmail
- AOL
- Newsvine
- HackerNews
- Evernote
- MySpace
- Mail.ru
- Viadeo
- Line
- Comments
- Yummly
- SMS
- Viber
- ‎
- Subscribe
- Skype
- Facebook Messenger
- Kakao
- LiveJournal
- Yammer
- Edgar
- Fintel
- Mix
- Instapaper
- Copy Link