Cool Pure CSS Buttons

So one of my work mate asked me how do we create buttons with CSS. I thought man! there are so many techniques that you can do it. So I am writing this post as a reference for him.

Before you use this technique let me tell you a couple of things

  1. Technique will only work on HTML pages with white backgrounds.
  2. If you want different colour buttons, just adjust hue/saturation of any button image provided within your Photoshop, but do not change the image or canvas size.

Lets take a look what final result will look like

 


 

 

 
 
 
 

 
 
 

And when I hover on Blue button this is what it will look like



 
 

Below is the code to achieve the above result
 
 

  1.  
  2. </head>
  3. <style type="text/css">
  4. a.button{
  5. cursor:pointer;
  6. line-height:27px;
  7. height:27px;
  8. padding-right:15px;
  9. font-family: tahoma, arial, verdana, "lucida sans unicode", sans-serif;
  10. padding-left:0px;
  11. display:inline-block;
  12. text-decoration:none !important;
  13. font-weight:bold;
  14. color:#FFF;
  15. }
  16.  
  17. a.greenbackright {background:url(green.jpg) no-repeat right top;}
  18. span.greenbackleft {background:url(green.jpg) no-repeat left top;}
  19.  
  20. a.greybackright {background:url(grey.jpg) no-repeat right top;}
  21. span.greybackleft {background:url(grey.jpg) no-repeat left top;}
  22.  
  23. a.bluebackright {background:url(blue.jpg) no-repeat right top;}
  24. span.bluebackleft {background:url(blue.jpg) no-repeat left top;}
  25.  
  26. a.redbackright {background:url(red.jpg) no-repeat right top;}
  27. span.redbackleft {background:url(red.jpg) no-repeat left top;}
  28.  
  29. a.button:hover {
  30. background-position:right -31px;
  31. text-decoration:none;
  32. font-weight:bold;
  33. color:#FFF;}
  34. a.button span {
  35. height:27px;
  36. line-height:27px;
  37. display:inline-block;
  38. padding-left:15px;
  39. text-decoration:none !important;
  40.  
  41. }
  42. a.button:hover span{background-position:left -31px;
  43. text-decoration:none;
  44. font-weight:bold;
  45. color:#FFF;}
  46.  
  47. <a href="#" class="button greenbackright"><span class="greenbackleft ">Click me</span></a><br><br>
  48.  
  49. <a href="#" class="button greybackright"><span class="greybackleft ">Click me</span></a><br><br>
  50.  
  51. <a href="#" class="button bluebackright"><span class="bluebackleft ">Click me</span></a><br><br>
  52.  
  53. <a href="#" class="button redbackright"><span class="redbackleft ">Click me</span></a><br>
  54.  
  55. </body>
  56. </html>

 

The images you can just download from below

 
 
 


 
 
 
 

 
 
 
 

 
 
 
 

 
 
 
 

I hope this helps. Leave your comments if you have any questions.

 
 
 

Cheers

Search Terms:

Jaspreet Chahal

Self-confessed Max Payne and Howzat Cricket game addict. Big fan of Dharmendra, Keanu reeves & Lawrence "Larry" Page. I love my Wife, my son and bit of geeky stuff. I started falling in love with Blog'in last year. Writing is tending out to be fun. I write on situation I was in thus my post always travel around web development stuff. I hope you enjoy my posts.

More Posts - Website

Follow Me:
TwitterFacebookPinterestYouTube

Comments

  1. Ahmad Najiullah says:

    nice trick,…
    thanks for sharing,…
    ^_^

Speak Your Mind

*

CommentLuv badge