CSS-Tricks Example

Button Examples:

Hey this is so cool!

Hey this is even cooler!
Now I think I'll write a whole sentence in the button!
So Neat!

Copy Paste Code:

HTML Code:

<div class="clearbutton"> <a class="GlobalOrangeButton" href="#"><span>So Neat!</span></a> </div>

CSS Code:

/* GLOBAL ORANGE BUTTON *****************************/
a.GlobalOrangeButton span {
background: transparent url('images/button_left_orange.png') no-repeat 0 0;
display: block;
line-height: 22px;
padding: 7px 0 5px 18px;
color: #fff;
}

a.GlobalOrangeButton {
background: transparent url('images/button_right_orange.png') no-repeat top right;
display: block;
float: left;
height: 34px;
margin-right: 6px;
padding-right: 20px;
text-decoration: none;
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
}

a.GlobalOrangeButton:hover span {
background-position: 0 -34px; color: #fff;
}

a.GlobalOrangeButton:hover {
background-position: right -34px;
}


Credits:

CREATED BY: Brandon Setter
WEBSITE: http://Media-Sprout.com
FOLLOW ME: twitter.com/bsetter
CREATION DATE: 10/2009
VERSION 1.0


I've found hundreds of tutorials on the sliding doors button and hundreds on the sprite technique but never a combination of both. This button combines the wonderful sprite technique with the sliding doors technique to make a beautiful button that not only loads in a snap but also looks great and scales to your text! I hope this is something useful for you! Please give me a shout-out if you like and use this code!


The 2 image files:


Download Source Files

Includes all code, images, and Photoshop image files.