Skip to content Skip to sidebar Skip to footer

Why Are There Gaps Between The Box-shadow And The Element?

When hovering over the button in Chrome (76.0.3809.100, 64-bit) faint gaps between the box-shadow and the img appear - why does this happen and how can I fix it? Here is an image i

Solution 1:

Add an extra inset box-shadow to reduce this effect:

body {
  background-color: firebrick;
}

button {
  all: unset;
  height: 200px;
  width: 200px;
  overflow: hidden;
}

button:hover > img {
  transform: scale(1.15);
}

button > img {
  height: 70%;
  margin: auto;
  display: block;
  box-shadow: 
   00050px#fff,
   0002px#fff inset;
}
<button><imgsrc="https://thewthr.app/img/search.png"></button>

A similar question: CSS rotated text with background shows some background-issues. Seems that any kind of transform create some issues with box-shadow

Post a Comment for "Why Are There Gaps Between The Box-shadow And The Element?"