Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Add Box Shadow around Image ignoring the Padding

I want to add a box-shadow to three images aligned next to each other. They all have a padding of 10px. When I apply the box shadow, it goes around the padding. I want it to go around the image, ignoring the padding.

.front-images {
  margin-top: 2%;
  display: flex;
  justify-content: center;
}
.front-images img {
  width: 100%;
  border-radius: 10px;
  padding: 10px;
  transition: 0.5s;
  box-shadow: 0 0 20px 0 rgba(0,0,0,0.5);
}
<div class="front-images">
    <img src="https://via.placeholder.com/200x200" alt="">
    <img src="https://via.placeholder.com/200x200" alt="">
    <img src="https://via.placeholder.com/200x200" alt="">
</div>

I also tried adding a margin property instead of padding but it doesn’t work. Is there a way to ignore the padding, adding the box shadow around the image?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

.front-images img {
    /* box-shadow: 0 0 20px 0 rgb(0 0 0 / 50%); */
    filter: drop-shadow(0px 0px 20px rgb(0 0 0 / 50%));
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading