Using box shadow to make bevel effect

2.2k views Asked by At

I have this css code, on which there is a tag. I styled it to bevel when I hover over it.

This is the css:

#slider-next {    
    padding:10px 60px;
    -webkit-border-radius: 25px;
  -moz-border-radius: 25px;
border-radius: 25px;
    background: -moz-linear-gradient(top, #28c4e3 0%, #0d5664 100%); /* firefox */

    text-shadow: 0 1px 2px #fff;
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#28c4e3), color-stop(100%,#0d5664)); /* webkit */font-size:20px}

#slider-next:hover {
    box-shadow:         0 1px 2px #fff, 0 -1px 1px #666, inset 0 -1px 1px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.8);
    -moz-box-shadow:    0 1px 2px #fff, 0 -1px 1px #666, inset 0 -1px 1px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.8);
    -webkit-box-shadow: 0 1px 2px #fff, 0 -1px 1px #666, inset 0 -1px 1px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.8);
     border: solid #ccc 3px;
}

And this is the html:

<span id="slider-next" style="float:right"></span>

What I want to do is when I hover over the span text, it bevels up, to give a button like effect. Right now it is beveling downwards.

How do I make it bend up? Here's a fiddle of it.

1

There are 1 answers

0
Maximillian Laumeister On

Just needed a quick tweak to the box-shadow values (I inverted the y values), now it looks a lot more like a button. Also, your prefixed box-shadow declarations should always come before the unprefixed ones.

Live Demo:

#slider-next {    
    padding:10px 60px;
    -webkit-border-radius: 25px;
  -moz-border-radius: 25px;
border-radius: 25px;
    background: -moz-linear-gradient(top, #28c4e3 0%, #0d5664 100%); /* firefox */

    text-shadow: 0 1px 2px #fff;
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#28c4e3), color-stop(100%,#0d5664)); /* webkit */font-size:20px}

#slider-next:hover {
    -moz-box-shadow:    0 -1px 2px #fff, 0 1px 1px #666, inset 0 -1px 1px rgba(0,0,0,0.5), inset 0 -1px 1px rgba(255,255,255,0.8);
    -webkit-box-shadow: 0 -1px 2px #fff, 0 1px 1px #666, inset 0 -1px 1px rgba(0,0,0,0.5), inset 0 -1px 1px rgba(255,255,255,0.8);
    box-shadow:         0 -1px 2px #fff, 0 1px 1px #666, inset 0 -1px 1px rgba(0,0,0,0.5), inset 0 -1px 1px rgba(255,255,255,0.8);
    border: solid #ccc 3px;
}
<span id="slider-next" style="float:left"></span>

JSFiddle Version: http://jsfiddle.net/g7YMV/4/