Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set both inset and outset box shadow using CSS

Tags:

css

The box-shadow property has a property value called inset, so the shadow can be inset, or outset.

But how is it possible, to set both inset, and outset shadow for a div in CSS?

like image 322
Iter Ator Avatar asked Mar 16 '14 14:03

Iter Ator


People also ask

Can you have multiple box shadows in CSS?

You can comma separate box-shadow any many times as you like.

How do I inset a shadow in CSS?

Approach: To give the inset shadow to an element, we will use the box-shadow property. In the box-shadow property, we will define the h-offset value ( It is compulsory for the horizontal shadow effect ), then the v-offset value (It is compulsory for the vertical shadow effect ).

How do you add a shadow to all sides of a box in CSS?

box-shadow: h-shadow v-shadow blur spread color inset; In your example you're offsetting shadow by 10px vertically and horizontally. Like in other comments set first two values to 0px in order to have even shadow on all sides.


2 Answers

You need to separate them using a ,

div {   margin: 50px;   height: 100px;   width: 100px;   border: 1px solid #aaa;   border-radius: 50%;   box-shadow: inset 0 0 5px tomato, 0 0 5px black; }
<div></div>

Demo

Demo 2 (Nothing different, but used white border for better indication)

So here in the above example, it sets the shadow inset with the tomato color, and the other set of rules separated using a comma is for outset i.e black shadow

like image 192
Mr. Alien Avatar answered Sep 21 '22 03:09

Mr. Alien


You need to use comma to separate both shadows.

div{     top: 100px;     position: absolute;     left: 100px;     height: 100px;     width: 100px;     box-shadow: 10px 10px 10px grey, 0 0 10px black;     border-radius: 5px;     background: white; } 

See demo

like image 45
newTag Avatar answered Sep 21 '22 03:09

newTag