March 27, 2012

How to make recessed button in CSS

Question by CodeDevelopr

In the image below, the top image is what I currently have on a site, it uses an actual Image.

What I want to do is make something more like the bottom image using pure CSS, I cannot figure out how to do it though, can anyone help?

enter image description here

Answer by theJollySin

CSS3 has a lot of solutions. Try this:

div.exampleboxshadowj {
background-color: #EEE;
float: left;
margin-top: 20px;
margin-right: 40px;
height: 65px;
width: 160px;
text-align: center;
-webkit-box-shadow: inset -5px -5px 5px 5px#888;
box-shadow: inset -5px -5px 5px 5px #888;
}

Though you can change the color to blue, if you want.

Here is a great link for all the info you could want.

Answer by Starx

If I understood you properly, you are trying to change the image when it is clicked or is active. If so, for that you can use :focus or :active to generate such effect.

Here is a demo with background color instead of a picture.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!