Transparent images use drop-shadow() filter function to create a shadow on the image's content, instead of box-shadow property which creates a rectangular shadow behind an element's entire box.
Icon: icons8.com
DEMO
box-shadow
drop-shadow
HTML
<div class="wrapper"> <div class="mr-2"> <div class="mb-1 text-center"> box-shadow </div> <img class="box-shadow" src="https://img.icons8.com/color/344/money-bag.png" alt="Image with box-shadow"> </div> <div> <div class="mb-1 text-center"> drop-shadow </div> <img class="drop-shadow" src="https://img.icons8.com/color/344/money-bag.png" alt="Image with drop-shadow"> </div> </div>
CSS
.wrapper { display: flex; align-items: center; justify-content: center; } .wrapper img { width: 100px; } .mr-2 { margin-right: 2em; } .mb-1 { margin-bottom: 1em; } .text-center { text-align: center; } .box-shadow { box-shadow: 2px 4px 8px #585858; } .drop-shadow { filter: drop-shadow(2px 4px 8px #585858); }
Comments
Post a Comment