I know about the box-shadow
property in CSS, but this produces a shadow that looks like being projected on a wall right behind the element. I need to create a shadow that looks like the element is standing on the ground like this:
This is what I have so far:
div {
display: inline-block;
height: 150px;
width: 150px;
background: url(//placehold.it/150x150);
margin-left: 20px;
box-shadow: -5px 5px 10px 0 rgba(0,0,0,0.75);
}
<div></div>
<div></div>
You can achieve this without using the
box-shadow
property on the element itself, but on the pseudo element::before
.transform: skewX(60deg);
will make it look like the light source is coming from the sideheight: 10%;
will make it look like projected on the groundwidth: 70%
and some positioning will hide the actual elementbox-shadow: -25px -4px 4px 0 rgba(0,0,0,0.75);
will produce the shadowOf course for older browsers you should use vendor prefixes.