Showing posts with label Font Awesome. Show all posts
Showing posts with label Font Awesome. Show all posts

Create Round Social Media Icons / Buttons using CSS

On 12/01/2017 12 Comments so far

Hi, in this post we'll see how to create round social media icons using pure CSS3. We all know how much impact do social signals have on websites and blogs. Here I'll show you the way to create clean and neat social media icons without images using a vector font library called Font Awesome. Font Awesome is the best icon font available and relatively easy to implement in your websites. They are highly scalable icons which means the social media icons we create will look good even in bigger size.

How to Create Social Network Icons with CSS?

To create these css social media icons, all we want to do is 1. Create some css styles, 2. Use Font awesome in those styles to draw up the icons and 3. Apply them to <a> anchor tag. No need to add <div>. You don't even have to download the fonts to use it in your website or blog. Just place the below <link> tag inside the <head> section of the HTML file.

<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"></link>

I have created 2 different styles of round social media icons for websites with 3D look.

Round CSS Social Media Icons - Style 1

This is a neat and elegant round button with slight raised look.

Demo
round-social-media-icons-html-css

Download Code View Demo

There are some properties which will be shared by every button and so in order to avoid repeated code, we just wrap them up in a global css class.

CSS for Global Button
.smGlobalBtn{ /* global button class */
    display: inline-block;
    position: relative;
    cursor: pointer;
    width: 50px;
    height: 50px;
    box-shadow: 0 2px 2px #999;
    padding: 0px;
    text-decoration: none;
    text-align: center;
    color: #fff;
    font-size: 25px;
    font-weight: normal;
    line-height: 2em;
    border-radius: 25px;
    -moz-border-radius:25px;
    -webkit-border-radius:25px;
}

CSS for Social Media Buttons
/* facebook button class*/
.facebookBtn{
    background: #4060A5;
}

.facebookBtn:before{ /* use :before to add the relevant icons */
    font-family: "FontAwesome";
    content: "\f09a"; /* add facebook icon */
}

.facebookBtn:hover{
    color: #4060A5;
    background: #fff;
}

/* twitter button class*/
.twitterBtn{
    background: #00ABE3;
}

.twitterBtn:before{
      font-family: "FontAwesome";
      content: "\f099"; /* add twitter icon */
}

.twitterBtn:hover{
      color: #00ABE3;
      background: #fff;
}

/* google plus button class*/
.googleplusBtn{
    background: #e64522;
}

.googleplusBtn:before{
      font-family: "FontAwesome";
      content: "\f0d5"; /* add googleplus icon */
}

.googleplusBtn:hover{
      color: #e64522;
      background: #fff;
}

/* linkedin button class*/
.linkedinBtn{
    background: #0094BC;
}

.linkedinBtn:before{
      font-family: "FontAwesome";
      content: "\f0e1"; /* add linkedin icon */
}

.linkedinBtn:hover{
      color: #0094BC;
      background: #fff;
}

/* pinterest button class*/
.pinterestBtn{
    background: #cb2027;
}

.pinterestBtn:before{
      font-family: "FontAwesome";
      content: "\f0d2"; /* add pinterest icon */
}

.pinterestBtn:hover{
      color: #cb2027;
      background: #fff;
}

/* tumblr button class*/
.tumblrBtn{
    background: #3a5876;
}

.tumblrBtn:before{
      font-family: "FontAwesome";
      content: "\f173"; /* add tumblr icon */
}

.tumblrBtn:hover{
      color: #3a5876;
      background: #fff;
}

/* rss button class*/
.rssBtn{
    background: #e88845;
}

.rssBtn:before{
      font-family: "FontAwesome";
      content: "\f09e"; /* add rss icon */
}

.rssBtn:hover{
      color: #e88845;
      background: #fff;
}

HTML Markup
<a class="facebookBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="twitterBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="googleplusBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="linkedinBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="pinterestBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="tumblrBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="rssBtn smGlobalBtn" href="social-media-profile-url" ></a>

Round CSS Social Media Icons - Style 2

The second style adds up some spice to the style 1 social media buttons by tweaking the code little bit. It's real charm lies in the hover style.

Demo
rounded-pure-css-social-media-icons

Download Code View Demo

Recommended Read: 5 Free Black and White Social Media Icons Sets using CSS

Recommended Read: Creating Social Media Icons in Bootstrap 3 | A How-To Guide

CSS for Global Button
.smGlobalBtn{ /* global button class */
    display: inline-block;
    position: relative;
    cursor: pointer;
    width: 50px;
    height: 50px;
    border:2px solid #ddd; /* add border to the buttons */
    box-shadow: 0 3px 3px #999;
    padding: 0px;
    text-decoration: none;
    text-align: center;
    color: #fff;
    font-size: 25px;
    font-weight: normal;
    line-height: 2em;
    border-radius: 27px;
    -moz-border-radius:27px;
    -webkit-border-radius:27px;
}

CSS for Social Media Buttons
/* facebook button class*/
.facebookBtn{
    background: #4060A5;
}

.facebookBtn:before{ /* use :before to add the relevant icons */
    font-family: "FontAwesome";
    content: "\f09a"; /* add facebook icon */
}

.facebookBtn:hover{
    color: #4060A5;
    background: #fff;
    border-color: #4060A5; /* change the border color on mouse hover */
}

/* twitter button class*/
.twitterBtn{
    background: #00ABE3;
}

.twitterBtn:before{
      font-family: "FontAwesome";
      content: "\f099"; /* add twitter icon */
      
}

.twitterBtn:hover{
      color: #00ABE3;
      background: #fff;
      border-color: #00ABE3;
}

/* google plus button class*/
.googleplusBtn{
    background: #e64522;
}

.googleplusBtn:before{
      font-family: "FontAwesome";
      content: "\f0d5"; /* add googleplus icon */
}

.googleplusBtn:hover{
      color: #e64522;
      background: #fff;
      border-color: #e64522;
}

/* linkedin button class*/
.linkedinBtn{
    background: #0094BC;
}

.linkedinBtn:before{
      font-family: "FontAwesome";
      content: "\f0e1"; /* add linkedin icon */
}

.linkedinBtn:hover{
      color: #0094BC;
      background: #fff;
      border-color: #0094BC;
}

/* pinterest button class*/
.pinterestBtn{
    background: #cb2027;
}

.pinterestBtn:before{
      font-family: "FontAwesome";
      content: "\f0d2"; /* add pinterest icon */
}

.pinterestBtn:hover{
      color: #cb2027;
      background: #fff;
      border-color: #cb2027;
}

/* tumblr button class*/
.tumblrBtn{
    background: #3a5876;
}

.tumblrBtn:before{
      font-family: "FontAwesome";
      content: "\f173"; /* add tumblr icon */
}

.tumblrBtn:hover{
      color: #3a5876;
      background: #fff;
      border-color: #3a5876;
}

/* rss button class*/
.rssBtn{
    background: #e88845;
}

.rssBtn:before{
      font-family: "FontAwesome";
      content: "\f09e"; /* add rss icon */
}

.rssBtn:hover{
      color: #e88845;
      background: #fff;
      border-color: #e88845;
}

HTML Markup
<a class="facebookBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="twitterBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="googleplusBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="linkedinBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="pinterestBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="tumblrBtn smGlobalBtn" href="social-media-profile-url" ></a>
<a class="rssBtn smGlobalBtn" href="social-media-profile-url" ></a>

Note: Font Awesome 4.0.3 doesn't support IE7, but older version does.

This is just a small sample of what CSS3 is capable of. You can extend the above css styles to create other social media buttons too. All you want is to unleash your creativity and play with the code. You’ll be amazed at the results. If you find this useful please don’t forget to share it :).

"Like this? I bet you will also want to read my another interesting tutorial on Creating Bootstrap 3 Social Media Icons using CSS. I have tried a different way of adding font awesome library combined with css to create 20 different social networking icons. Check it out here."

5 Free Black and White Social Media Icons Sets with CSS and HTML

On 11/28/2017 1 Comment so far

Hi! In this article I've come up with 5 modern sets of black and white social media icons using pure css3 and html code. As social media plays major role in creating brand awareness, one cannot overlook the importance of implementing social sharing buttons in their websites. And this article is going to help you with five different styles of social icons to use in your websites. Moreover these icons are built without using images which will improve your website's loading speed too.

free-black-and-white-social-media-icons-html-css

Like my earlier tutorials on pure css social media icons, this post too will use font awesome library. Font Awesome is a scalable vector font library and its icons can be easily customized using css to fit with the rest of your website's theme. It is originally developed for bootstrap but works great with all the other frameworks and even with plain html.

Load Font Awesome Library in HTML File

To use these css social media icons you need font awesome library. Use this line of code inside <head></head> section to load font awesome in the html file.

<link type="text/css" rel="stylesheet" href="path-to-fontawesome/font-awesome.css">

You can either download font awesome and use it locally or link directly from cdn. Check its official website to learn more.

The HTML Code for Social Media Icons

The html markup for including the social sharing buttons will be the same for all the 5 different styles discussed in this post. Only their css code will vary. So use this html code wherever you want to add social icons in your website along with the css code given in this article.

<div class="socialbtns">
    <ul>
        <li><a href="#" class="fa fa-lg fa-facebook"></a></li>
        <li><a href="#" class="fa fa-lg fa-twitter"></a></li>
        <li><a href="#" class="fa fa-lg fa-google-plus"></a></li>
        <li><a href="#" class="fa fa-lg fa-github"></a></li>
        <li><a href="#" class="fa fa-lg fa-pinterest"></a></li>
        <li><a href="#" class="fa fa-lg fa-linkedin"></a></li>
        <li><a href="#" class="fa fa-lg fa-instagram"></a></li>
        <li><a href="#" class="fa fa-lg fa-vimeo-square"></a></li>
        <li><a href="#" class="fa fa-lg fa-stack-overflow"></a></li>
        <li><a href="#" class="fa fa-lg fa-dropbox"></a></li>
        <li><a href="#" class="fa fa-lg fa-tumblr"></a></li>
        <li><a href="#" class="fa fa-lg fa-envelope"></a></li>
        <li><a href="#" class="fa fa-lg fa-flickr"></a></li>
        <li><a href="#" class="fa fa-lg fa-bitbucket"></a></li>
        <li><a href="#" class="fa fa-lg fa-dribbble"></a></li>
        <li><a href="#" class="fa fa-lg fa-search"></a></li>
        <li><a href="#" class="fa fa-lg fa-skype"></a></li>
        <li><a href="#" class="fa fa-lg fa-stack-exchange"></a></li>
        <li><a href="#" class="fa fa-lg fa-youtube"></a></li>
        <li><a href="#" class="fa fa-lg fa-xing"></a></li>
        <li><a href="#" class="fa fa-lg fa-rss"></a></li>
        <li><a href="#" class="fa fa-lg fa-foursquare"></a></li>
        <li><a href="#" class="fa fa-lg fa-youtube-play"></a></li>
        <li><a href="#" class="fa fa-lg fa-cloud"></a></li>
    </ul>
</div>

The above markup will add an unordered list of links. Now we have to style these plain looking icons with css.

The CSS Code for Social Media Icons

As I already said, these are highly customizable icons. Adding a few lines of css code will turn these icons into some unique style. Here goes the trick.

Style 1 - Black and White Minimal Social Media Icons

black-and-white-minimal-social-media-icons

DEMO

The first style is the minimal looking black and white social media icons. As the name implies, these are very stylish and minimal looking icons set that gives a clean and elegant look to your website. All these icons will simply be outlined in black color and the inner portion gives a hollow appearance. On mouse hover they will gradually ease into solid black icons. I have used multiple text shadows to bring out the outline effect to icons and css3 transition property to guarantee smooth animation effect to them.

Here goes the css code for minimal social media icons.

/* minimal sm icons */
a, a:hover {
    color: #000;
    text-decoration: none;
    padding: 5px;
}

.socialbtns, .socialbtns ul, .socialbtns li {
    margin: 0;
    padding: 5px;
}

.socialbtns li {
    list-style: none outside none;
    display: inline-block;
}

.socialbtns .fa {
    color: #FFF;
    text-shadow: 1px 1px 0px #000,
            1px -1px 0px #000,
            -1px 1px 0px #000,
            -1px -1px 0px #000;
    -webkit-text-shadow: 1px 1px 0px #000,
            1px -1px 0px #000,
            -1px 1px 0px #000,
            -1px -1px 0px #000;
    -moz-text-shadow: 1px 1px 0px #000,
            1px -1px 0px #000,
            -1px 1px 0px #000,
            -1px -1px 0px #000;
    -o-text-shadow: 1px 1px 0px #000,
            1px -1px 0px #000,
            -1px 1px 0px #000,
            -1px -1px 0px #000;
    transition: all ease-out 0.5s;
    -moz-transition: all ease-out 0.5s;
    -webkit-transition: all ease-out 0.5s;
    -o-transition: all ease-out 0.5s;
}

.socialbtns .fa:hover {
    color: #000;
    text-shadow: 1px 1px 0px #fff,
            1px -1px 0px #fff,
            -1px 1px 0px #fff,
            -1px -1px 0px #fff;
    -webkit-text-shadow: 1px 1px 0px #fff,
            1px -1px 0px #fff,
            -1px 1px 0px #fff,
            -1px -1px 0px #fff;
    -moz-text-shadow: 1px 1px 0px #fff,
            1px -1px 0px #fff,
            -1px 1px 0px #fff,
            -1px -1px 0px #fff;
    -o-text-shadow: 1px 1px 0px #fff,
            1px -1px 0px #fff,
            -1px 1px 0px #fff,
            -1px -1px 0px #fff;
    transition: all ease 0.5s;
    -moz-transition: all ease-in 0.5s;
    -webkit-transition: all ease-in 0.5s;
    -o-transition: all ease-in 0.5s;
}

Style 2 - Classic Square Black and White Social Media Icons

create-social-media-icons-for-website

DEMO

The second style is of a classic square icons set with white logo against solid black background. The square icons will ease into circle with smooth transition on hover. By increasing the border radius property of all the four corners of the icons, we can easily turn the square button into a circular one. The css transition will ensure you a smooth animation effect. Here goes the css code for the square social icons.

/* square sm icons */
a, a:hover {
    text-decoration: none;
}

.socialbtns, .socialbtns ul, .socialbtns li {
    margin: 0;
    padding: 5px;
}

.socialbtns li {
    list-style: none outside none;
    display: inline-block;
}

.socialbtns .fa {
    width: 40px;
    height: 28px;
    color: #FFF;
    background-color: #000;
    padding-top: 12px;
    transition: all ease 0.5s;
    -moz-transition: all ease 0.5s;
    -webkit-transition: all ease 0.5s;
    -o-transition: all ease 0.5s;
}

.socialbtns .fa:hover {
    border-radius: 20px;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -o-border-radius: 20px;
    transition: all ease 0.5s;
    -moz-transition: all ease 0.5s;
    -webkit-transition: all ease 0.5s;
    -o-transition: all ease 0.5s;
}

Style 3 - Black and White Rounded Social Media Icons

black-and-white-pure-css-social-media-icons

DEMO

This is another one interesting style of icons set. Rounded Social Media Icons are always alluring and being black and white round icons, these are no exceptions to that. The icons are circular in shape with white logo against black background color and on mouse hover they will zoom out from the rest of the icons. This zooming effect is generated by scaling up the icon by one third of its size. Even at the bigger size these icons will look awesome. Adding smooth animation just gives you an illusion as though these icons zoom in and out without hitches. Here goes the css for these rounded social media icons.

/* round sm icons */
a, a:hover {
    text-decoration: none;
}

.socialbtns, .socialbtns ul, .socialbtns li{
    margin: 0;
    padding: 5px;
}

.socialbtns li {
    list-style: none outside none;
    display: inline-block;
}

.socialbtns .fa {
    width: 40px;
    height: 28px;
    color: #FFF;
    background-color: #000;
    padding-top: 12px;
    border-radius: 20px;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -o-border-radius: 20px;
    transition: all ease 0.5s;
    -moz-transition: all ease 0.5s;
    -webkit-transition: all ease 0.5s;
    -o-transition: all ease 0.5s;
}

.socialbtns .fa:hover {
    transform: scale(1.2,1.2);
    -moz-transform: scale(1.2,1.2);
    -webkit-transform: scale(1.2,1.2);
    -o-transform: scale(1.2,1.2);
    transition: all ease 0.5s;
    -moz-transition: all ease 0.5s;
    -webkit-transition: all ease 0.5s;
    -o-transition: all ease 0.5s;
}

Style 4 - Hollow Social Media Icons with Outer Ring

black-and-white-round-social-media-icons

DEMO

These hollow looking icons are somewhat similar to the third style but without solid fill of black color, these icons will give you a hollow effect with black outer ring. On mouse hover, it fills out beautifully with solid black background color. Here is the css code for it.

/* hollow sm icons */
a, a:hover {
    text-decoration: none;
}

.socialbtns, .socialbtns ul, .socialbtns li {
    margin: 0;
    padding: 5px;
}

.socialbtns li {
    list-style: none outside none;
    display: inline-block;
}

.socialbtns .fa {
    width: 40px;
    height: 28px;
    color: #000;
    background-color: #FFF;
    border: 1px solid #000;
    padding-top: 12px;
    border-radius: 22px;
    -moz-border-radius: 22px;
    -webkit-border-radius: 22px;
    -o-border-radius: 22px;
}

.socialbtns .fa:hover {
    color: #FFF;
    background-color: #000;
    border: 1px solid #000;
}

Style 5 - Black and White Spinning Social Media Icons

spinning-css3-social-media-icons

DEMO

Here goes the crazy stuff. Yep! The final set is of spinning social media icons in black and white. This is a beautiful pack of flat and round social media icons which on mouse hover, spin off 360 degree and ease out in the reverse direction when the mouse pointer leaves the icon. The css3 transform property ensures a smooth rotation of the icons that spin in clockwise and anti-clockwise direction. Here is the css code for spinning social media icons.

/* spinning sm icons */
a, a:hover {
    text-decoration: none;
}

.socialbtns, .socialbtns ul, .socialbtns li {
    margin: 0;
    padding: 5px;
}

.socialbtns li {
    list-style: none outside none;
    display: inline-block;
}

.socialbtns .fa {
    color: #FFF;
    background-color: #000;
    width: 40px;
    height: 28px;
    padding-top: 12px;
    border-radius: 20px;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -o-border-radius: 20px;
    transition: all ease 0.3s;
    -moz-transition: all ease 0.3s;
    -webkit-transition: all ease 0.3s;
    -o-transition: all ease 0.3s;
}

.socialbtns .fa:hover {
    transition: all ease 0.3s;
    -moz-transition: all ease 0.3s;
    -webkit-transition: all ease 0.3s;
    -o-transition: all ease 0.3s;
    transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
}

I have included more than 25 social sharing icons here for you to pick out. Just remember, including too many social sharing buttons will confuse the reader. So choose wisely where your websites audience hang out most.

Read Also

I hope you love these black and white social media icons collections.

How to Add Social Media Icons to Twitter Bootstrap NavBar

On 11/22/2017 13 Comments so far

One cannot simply overlook social media marketing in creating brand awareness and the need to implement social sharing icons to websites and blogs. Having social signals on prime spots where the site users cannot miss is a challenging task and top navigation menu is one such place in any website. I have already discussed here about using font-awesome icon font to add social network buttons to bootstrap websites. And this bootstrap tutorial will walk you through in easy steps to add customized social media icons to twitter bootstrap navbar.

Add Social Media Icons To Twitter Bootstrap NavBar

To add social network icons to bootstrap navbar (navigation menu) we need some libraries. First download the required libraries used in this bootstrap tutorial.

Once you have downloaded the files, unzip them and move them to your working folder.

Next you have to include bootstrap, font-awesome and jquery files appropriately in the html file, add some markup and little bit of css styles to start with.

Step-1: Create an html file ‘index.html’ and add the Bootstrap and Font-Awesome css files within the head section of html.

<link href="/path/to/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="/path/to/font-awesome.css" rel="stylesheet" type="text/css" />

Step-2: Next add jQuery and Bootstrap javascript files above the closing body tag (</body>) of html.

<script src="/path/to/jquery-1.10.2.js"></script>
<script src="/path/to/bootstrap.min.js"></script>

Step-3: Having all the required css and js files in place now we have to move on to the task of building navigation menu in twitter bootstrap. Add the below html markup to create navigation menu alias navbar in bootstrap.

<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <!-- add header -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">TrendZZ</a>
        </div>
        <!-- menu items -->
        <div class="collapse navbar-collapse" id="navbar1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Mens</a></li>
                <li><a href="#">Womens</a></li>
                <li><a href="#">Kiddies</a></li>
            </ul>
        </div>
    </div>
</nav>

Now open the ‘index.html’ in browser and you will see a navbar component with some menu items on the left side.

Step-4: Now let us add the social network icons for facebook, twitter, google plus and linkedin to the right side of this navbar. We have to use font-awesome brand icons for this purpose. Lets rewrite the <nav> element markup we have added earlier.

<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <!-- add header -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">TrendZZ</a>
        </div>
        <!-- menu items -->
        <div class="collapse navbar-collapse" id="navbar1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Mens</a></li>
                <li><a href="#">Womens</a></li>
                <li><a href="#">Kiddies</a></li>
            </ul>
            <!-- social media icons -->
            <ul class="nav navbar-nav navbar-right social">
                <li><a href="#"><i class="fa fa-lg fa-facebook"></i></a></li>
                <li><a href="#"><i class="fa fa-lg fa-twitter"></i></a></li>
                <li><a href="#"><i class="fa fa-lg fa-google-plus"></i></a></li>
                <li><a href="#"><i class="fa fa-lg fa-linkedin"></i></a></li>
            </ul>
        </div>
    </div>
</nav>

It’s done!! Now run the html file in browser and you will see nicely scaled little gray colored icons to the right side of the navbar.

twitter-bootstrap-3-social-media-icons-navbar
Font-Awesome Social Media Icons in Bootstrap Navbar

Here comes the best part of twitter bootstrap library. We haven’t written a single piece of css styles of our own but all the social icons are aligned properly in the bootstrap navbar component.

Wonder how this happened? As discussed many times here in www.kodingmadesimple.com, bootstrap has predefined css styles that makes web development lot easier. Though these social media icons looks great, sure enough we have to write down few additional css styles to fine tune the look and behavior of the icons.

Step-5: Create a css stylesheet with name ‘custom.css’ and link it below the bootstrap and font-awesome files to override css styles.

<link href="/path/to/custom.css" rel="stylesheet" type="text/css" />

Step-6: Next add this below css style to the custom css file.

.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
    color: #777;
}

Step-7: Now you are okay with the above styles but even though the social icons will turn into dark grey on hover state. Let’s add some spice to it and turn on the social icons color to respective brand colors on mouse hover state. Add these additional css styles to ‘custom.css’.

.social .fa-facebook:hover {
    color: #4060A5;
}

.social .fa-twitter:hover {
    color: #00ABE3;
}

.social .fa-google-plus:hover {
    color: #e64522;
}

.social .fa-linkedin:hover {
    color: #0094BC;
}

Now save the files and refresh ‘index.php’ in the browser and viola...!!

All the social networking icons turn out nicely into their brand colors on hover state.

twitter-bootstrap-3-social-media-icons-hover-navbar
Font-Awesome Social Media Icons Hover State in Bootstrap Navbar

Complete HTML Markup for index.html

<!DOCTYPE html>
<html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8">
    <title>Twitter Bootstrap Social Media Icons to Navbar</title>
    <link href="/path/to/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="/path/to/font-awesome.css" rel="stylesheet" type="text/css" />
    <link href="/path/to/custom.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <nav class="navbar navbar-default" role="navigation">
        <div class="container-fluid">
            <!-- add header -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">TrendZZ</a>
            </div>
            <!-- menu items -->
            <div class="collapse navbar-collapse" id="navbar1">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">Mens</a></li>
                    <li><a href="#">Womens</a></li>
                    <li><a href="#">Kiddies</a></li>
                </ul>
                <!-- social media icons -->
                <ul class="nav navbar-nav navbar-right social">
                    <li><a href="#"><i class="fa fa-lg fa-facebook"></i></a></li>
                    <li><a href="#"><i class="fa fa-lg fa-twitter"></i></a></li>
                    <li><a href="#"><i class="fa fa-lg fa-google-plus"></i></a></li>
                    <li><a href="#"><i class="fa fa-lg fa-linkedin"></i></a></li>
                </ul>
            </div>
        </div>
    </nav>
    <script src="/path/to/jquery-1.10.2.js"></script>
    <script src="/path/to/bootstrap.min.js"></script>
</body>
</html>

Complete CSS Code for custom.css

.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
    color: #777;
}

.social .fa-facebook:hover {
    color: #4060A5;
}

.social .fa-twitter:hover {
    color: #00ABE3;
}

.social .fa-google-plus:hover {
    color: #e64522;
}

.social .fa-linkedin:hover {
    color: #0094BC;
}

And that was all about adding social media icons to bootstrap navbar. If you want to use some other brand icons other than the one given here, then check out this font awesome social media icons in bootstrap tutorial as there are more than twenty different social network icons are given.

Recommended Read:

5 Star Rating System using jQuery, CSS and Font Awesome

On 8/29/2017 Be the first to comment!

Hey! Today I'm going to show you how to create a simple 5 star rating system using jquery and pure css. Star Rating System is very popular online and is used in most of the websites these days. It allows users to rate contents, comments, reviews etc. and let others know if it is good or bad. There is a wide range of star rating plug-ins available in the market. But I'm going to show you a dead simple way to implement this 5-star rating system without using any plug-ins. All we need is jquery library and css.

star rating system jquery css font awesome

Building jQuery 5-Star Rating System:

To implement the star rating system, we must create a list of stars that looks empty or gray by default. The stars should be highlighted when the mouse hover over them and turn to gray when it exit to a different area of the webpage. And the rating should be counted when the user clicks on the stars and the value should be preserved in a hidden text field.

Read: Create Fullscreen Video Background using HTML5 & CSS

For the stars I'm not going to use images, but the vector icon library, 'Font Awesome'. I have already used it in a tutorial about creating social sharing buttons. The library is easy to use and can create scalable vector icons which you can style with css.

Step 1) Load Required Libraries

We'll need two libraries for building the star rating system, one is jquery and the other is font awesome. Hence we'll first load them in our web page.

<head>
    <link href="path/to/font-awesome.css" rel="stylesheet" type="text/css" />
    <script src="path/to/jquery-1.10.2.js"></script>
</head>

Step 2) Creating HTML List of Stars

Next we have to add a set of stars to the page. For that we will use the html list and add the 'star' icon from font-awesome lib.

<input id="star_rating" name="star_rating" type="hidden" />
<ul>
    <li><i class="fa fa-star fa-fw"></i></li>
    <li><i class="fa fa-star fa-fw"></i></li>
    <li><i class="fa fa-star fa-fw"></i></li>
    <li><i class="fa fa-star fa-fw"></i></li>
    <li><i class="fa fa-star fa-fw"></i></li>
</ul>
<div id="msg" name="msg"></div>

In the above markup we have also included a hidden text box to store the user rating and a placeholder to display the notification to users.

Step 3) Add Some CSS Styling

It's time to add some css styles to prettify the plain looking stars.

<style type="text/css">
ul {
    margin: 0;
    padding: 0;
}

li {
    font-size: 30px;
    color: #F0F0F0;
    display: inline-block;
    text-shadow: 0 0 1px #666666;
}

#msg {
    color: #A6A6A6;
    font-style: italic;
}
</style>

Okay! The above styles will produce a page with 5 stars like this one,

star rating tutorial jquery css

As I have said before, stars should be highlighted when the user clicks or hover mouse over it. So we need to add css style for highlighting stars in yellow.

.highlight-stars {
    color: #F4B30A;
    text-shadow: 0 0 1px #F4B30A;
}

Read: How to Store Image into Database with PHP & MySQL

Step 4) jQuery Script

Finally we have to add some jquery functions for the rating system to work. Even though we have stars and everything, nothing will happen unless we have some UI interactive functions. Here we have to write mouse handlers to highlight / un-highlight the stars when the user hover over the stars or leave them. And when they click on the stars the rating should be stored in the hidden field and notified to the user with a message.

<script type="text/javascript">
$(document).ready(function(){
    $('li').mouseover(function(){
        obj = $(this);
        $('li').removeClass('highlight-stars');
        $('li').each(function(index){
            $(this).addClass('highlight-stars');
            if(index == $('li').index(obj)){
                return false;
            }
        });
    });

    $('li').mouseleave(function(){
        $('li').removeClass('highlight-stars');
    });

    $('li').click(function(){
        obj = $(this);
        $('li').each(function(index){
            $(this).addClass('highlight-stars');
            $('#star_rating').val((index+1));
            $('#msg').html('Thanks! You have rated this ' + (index+1) + ' stars.');
            if(index == $('li').index(obj)){
                return false;
            }
        });
    });

    $('ul').mouseleave(function(){
        if($('#star_rating').val()){
            $('li').each(function(index){
                $(this).addClass('highlight-stars');
                if((index+1) == $('#star_rating').val()){
                    return false;
                }
            });
        }
    });
});
</script>

Done! Now we have everything in place. Run the page in the browser and you'll see 5-star rating system. Hover over the stars and click on them to rate it and you can see a message on the rating you have provided.

jquery 5 star rating system

Store User Rating into Database:

In case you want to store user rating in the database, you need to do it with the help of some server scripts like php.

Remember we have retained the rating in a hidden text box? You can simply submit the form using ajax and access the rating field value with php.

Here is a rough php script to get the user rating and store it in mysql database.

<?php
// store user rating into mysql db
$rating = $_POST["star_rating"];
$con = mysqli_connect("localhost", "root", "", "db_rating") or die("Error " . mysqli_error($con));
$sql = "INSERT INTO tbl_rating(rating, timestamp) VALUES('" . $rating . "', '" . @date('Y-m-d H:i:s') . "')";
mysqli_query($con, $sql) or die("Error " . mysqli_error($con));
?>

Read: How to Lazy Load Images using PHP and JavaScript

That's how you can implement 5 star rating system using jquery, css and font awesome. There's no need to use third party plug-ins to add user rating system to your website. I hope you find this tutorial useful. Please don't forget to share it in social media.

Contact Form

Name

Email *

Message *