Blog

date7. May 2010

Stop buttons without click effect!

Sorry, i know this has nothing to do with moneybook, but i hate, yes really hate buttons without click effect! It feels so unnatural when you click on it. So i feel me morally obliged to show how to make a click effect with CSS.

1. First you need the 3 states of a button in one image. You can also do it with two, but hey we want a hover effect you know ;)

2. After this you can write some code like this.

HTML
Everything what you need is a a tag between a p tag with the ID “clickable”.

CSS
If your image with the 3 buttons is 300px height so you have to put 100px for the height (image height divide by three)

p#clickable a {
float : left;
width : 125px;
height : 100px;
background : url(clickable.png) no-repeat;
cursor: pointer;
}

p#clickable a:hover {
background-position : center;
}

p#clickable a:active {
background-position : bottom;
}

So that’s it! Let us make this world to a better place with clickable buttons!

comments Comments (8)

8 Comments

Leave a comment

FAQ | impressum