Create a social network sharing button

For your blog posts or on the pages that present your projects from a portfolio, presenting a modern, non-intrusive button to allow your visitors to share your website or go to your social networks is ideal. Let's look at how to create this type of button together in this article.
•
Updated on August 14, 2026
•
3 min read
Believemy logo

For your blog articles or on pages that showcase your projects from a portfolio, presenting a modern and non-intrusive button to allow your visitors to share your website or visit your social networks is ideal. Let's see how to create this type of button together in this article.

Image

 

Step 1

Include Font Awesome.

HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">

To display social network icons, we will use a library made for that: Font Awesome!

 

Step 2

Time for HTML!

HTML
<div class="box">
  <input type="checkbox" id="checkbox" />
  <div class="menu">
    <a href="#">
      <div class="menuItems">
        <i class="fab fa-whatsapp"></i>
      </div>
    </a>
    <a href="#">
      <div class="menuItems">
        <i class="fab fa-instagram"></i>
      </div>
    </a>
    <a href="#">
      <div class="menuItems">
        <i class="fab fa-facebook"></i>
      </div>
    </a>
    <a href="#">
      <div class="menuItems">
        <i class="fab fa-twitter"></i>
      </div>
    </a>
  </div>
</div>

Each fab class is a class used by Font Awesome.

This library will automatically handle displaying the icons at the places where we declare our classes.

Do you already see the trickery?

We will simply declare the first element (before) towards the top left, and the second (after) towards the bottom right. This will give the impression that our button's borders are doubling.

 

Step 3

Let's now style the box class and the checkbox.

CSS
.box {
  display: flex;
}

#checkbox {
  width: 65px;
  height: 65px;
  cursor: pointer;
  appearance: none;
  -moz-appearance: none;
  -webkit-appearance: none;
  outline: none;
  background: white;
  position: relative;
}
#checkbox:hover {
  background: rgba(255, 255, 255, .7);
}

 

Step 4

Let's move on to the before element.

CSS
#checkbox::before {
  content: '\f1e0';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'font awesome 5 free';
  font-weight: 700;
  font-size: 1.5rem;
  color: rgb(41, 41, 41);
  transition: all 1.5s;
}
#checkbox:checked::before {
  content: '\f00d';
}
#checkbox:checked ~ .menu {
  width: 264px; /* 4 * 65 + 4 * 1 for the border */
}

When we write “\f1e0” or “\f00d”, it is actually a Font Awesome code to indicate that we want a share icon and a cross.

The share icon is displayed when we have not clicked on our checkbox.

The cross icon is displayed when we have clicked on it.

This allows us to tell our user that they can close the menu. They appear because we are using the Font Awesome font “font awesome 5 free”.

 

Step 5

Let's style the menu.

CSS
.menu {
  width: 0;
  display: flex;
  overflow: hidden;
  transition: all .5s;
}
.menu .menuItems {
  width: 65px;
  height: 65px;
  background: white;
  border-left: 1px solid rgb(165, 165, 165);
  display: flex;
  justify-content: center;
  align-items: center;
}
.menu .menuItems:hover {
  background: rgba(255, 255, 255, .7);
}

 

Step 6

All that's left is to change the color of each icon.

CSS
.menu .menuItems i {
  font-size: 1.8rem;
}
.fa-whatsapp {
  color: #25d366;
}
.fa-instagram {
  color: #c32aa3;
}
.fa-facebook {
  color: #273c75;
}
.fa-twitter {
  color: #1da1f2;
}
Category: Developers

Share this article

Want to help us? Share this article on your networks or even better: on your site, in an article or in your newsletter.

Believemy logo
Comments (0)

You need to be logged in to comment on this article: log in or sign up.

Read next

Create a share button pasted at the bottom of the page with CSS

Displaying a social networking sharing button on your site helps to increase the number of visits. Nowadays, it has become essential to offer this kind of button whenever we publish articles or project presentations. Let's find out how to set up this kind of button in this article!

December 9, 2024

Creating circled buttons on hover with HTML and CSS

For a menu or to encourage your readers to share your website, share buttons are essential elements to add to your website. Let's find out how to make them more modern with a "neon" effect that will surround the icon selected by your user.

December 9, 2024

Add a "click to copy" button with JavaScript

Would you like to make it quick and easy for your users to copy text onto your project? That famous link to share your article? That affiliate link that helps you generate extra sales? Then this article is for you! Let's take a look at the two main methods for adding a "click to copy" button with the help of JavaScript.

December 9, 2024

Creating a NEON button with CSS

Creating a button is one thing! But creating a button that your visitors want to click is something else entirely. In any case, this neon button will catch the eye of everyone who visits your pages.

December 9, 2024

Create a heartbeat button

For a main button or even for a button you want to highlight, offering this heartbeat effect can give your website a very modern feel. Find out how in this article.

December 6, 2024

Create a very modern hover on a link

Here's an easy way to create a very modern hover on a link! There are lots of possible effects for buttons and links: the better they look, the more likely your users will be to click on them.

December 9, 2024

Playing with blurs and filters on presentation cards with CSS

Looking for a way to display your latest blog posts or projects in a modern, animated way? These cards will go perfectly with your website! Let's find out how to make them.

December 9, 2024

Creating an "Old School" button with CSS

Let's find out how to create an original button that's right up to date!

December 9, 2024

Become the solopreneur you dream of being.

First project, career change, business launch: access our courses, practice on real-world cases, and move forward with clear guidance.