Create Facebook and Twitter button using CSS3

After released CSS3, I have practiced with it’s new features. After watching one tutorial i got an idea to make something nice. Then I am tried to build Facebook and Twitter button using CSS3 without using any image. And try to use some nice CSS tricks to make these button more realistic.

And one thing, I will not discuss the CSS3 new features format and params. I will just show how I have used these feature to create FB and Twitter button. Lets Start How I do that.

demodownload

Here is the List some of CSS3 property I have used to do this:

  • font-face
  • Gradient
  • Border radius
  • Text & Box Shadow
  • Other properties

Font-face

I have used font-face kit from here. To get the Facebook ‘f’ and Twitter ‘t’ I have used that. I have created Font by this font-face kit. And use this font later.

@font-face {
font-family: 'ModernPictogramsNormal';
src: url('font/modernpics-webfont.eot');
src: url('font/modernpics-webfont.eot?#iefix') format('embedded-opentype'),
url('font/modernpics-webfont.woff') format('woff'),
url('font/modernpics-webfont.ttf') format('truetype'),
url('font/modernpics-webfont.svg#ModernPictogramsNormal') format('svg');
font-weight: normal;
font-style: normal;
}

Gradients

You can see Gradients syntax/format here. Then if you want you can make your own Gradient visually Here.

Here My Used Gradient for FB Icon:

/* Background Credients */
    background: #014464;
    background-image: -webkit-gradient(
        linear,
        left bottom,
        left top,
        color-stop(0.4, #2E6C9E),
        color-stop(0.51, #1A5399),
        color-stop(0.6, #2774B8)
        );

Border radius

Border radius is a nice feature of CSS3. You can see the other property here Or you can create visually here.

 /* Border & Border Radius */
    -moz-border-radius:10px;
    -moz-border-radius:10px;
    border-radius:10px;
    border: 1px solid #368DBE;
    border-top: 1px solid #e3d6df;
    border-left: 1px solid #e3d6df;

Text & box shadow

Box-shadow, one of CSS3′s best new features. You can see details of Box shadow here.

To make the button more interactive I have used Text shadow. You can see some use of Text shadow here. here.

  /* Text Shadow */
    text-shadow: 0px -1px 1px #111;

    /* Box shadow */
    -moz-box-shadow: 0 1px 3px black;
    -webkit-box-shadow: 0 1px 3px black;
    box-shadow: 0 3px 8px black;

Others

To make interactive button I have added shadow while button active.

/*     WHILE BEING CLICKED   */
.button:active {
    -moz-box-shadow: 0 2px 6px black;
    -webkit-box-shadow: 0 2px 6px black;
}

Then I have used the Font i have made by font face.

.button:after {
    font-family: ModernPictogramsNormal;
    content: 'F';
    color: #FFF;
    font-size: 60px;
    float: left;
    margin-left: 15px;
    margin-right: -10px;
    text-shadow: 1 1px 1 #4190AF;
}

And here is the other normal CSS I have used for create the button.

.button {
    width: 55px;
    height: 55px;
    line-height: 63px;
    text-decoration: none;
    color: white;
    font-size: 40px;
    font-family: helvetica, arial;
    font-weight: bold;
    display: block;
    text-align: center;
}

I have shown all the CSS I have used for Facebook button. To see the Twitter button source download it from github. And you also can see the inspiring tutorials at Nettuts+

Cheers!!!

Leave a comment