Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: What's a good way to create a raised box effect?

Tags:

css

border

effect

That is, the left and bottom borders of the element need to give a 3d effect of it popping out. Is there a good, purely-CSS way to accomplish this effect?

like image 807
Hamster Avatar asked Jan 06 '11 21:01

Hamster


People also ask

How do you make a beautiful box shadow in HTML and CSS?

The code for the shadow is: box-shadow: rgb(204, 219, 232) 3px 3px 6px 0px inset, rgba(255, 255, 255, 0.5) -3px -3px 6px 1px inset; The keyword inset is used to specify that we want to use the shadow inwards and not the default behaviour that is outwards .

What is box shadow CSS?

The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple effects separated by commas. A box shadow is described by X and Y offsets relative to the element, blur and spread radius, and color.


2 Answers

#foo {
    /* ... */
    border:8px outset #999;
    -webkit-box-shadow: 5px 5px 15px rgba(0,0,0,0.4);
    -moz-box-shadow: 5px 5px 15px rgba(0,0,0,0.4);
}

Here's the example live: http://jsfiddle.net/sjkXS/1/
Yes, the effect here is cheesily-extreme, indended to showcase what is possible.

like image 97
Phrogz Avatar answered Oct 23 '22 07:10

Phrogz


I found this question while trying to figure this out as well, and I think what you're looking for is something like this http://jsfiddle.net/9Lt2477w/.

.raisedbox { 
    padding: 10px;
    border: 1px solid #77aaff;
    box-shadow:  -1px 1px #77aaff,
         -2px 2px #77aaff,
         -3px 3px #77aaff,
         -4px 4px #77aaff,
         -5px 5px #77aaff;
}

Thanks to http://sam-morrow.com/playground/css-cubes.py for the help here. I didn't realize you could just keep adding additional lines into the box-shadow property.

like image 21
Brandon Avatar answered Oct 23 '22 06:10

Brandon