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?
You can comma separate box-shadow any many times as you like.
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 ).
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With