How to add a circular background to a gif using css

Viewed 267

I want to add a circular background behind this gif.

<img src="https://media.giphy.com/media/WFZvB7VIXBgiz3oDXE/giphy.gif" class="code-img" alt="Code">

I tried adding the following css properties

.code-img {
  background-color: #66BFBF;
  border-radius: 100%;
  padding: 30px;
  width: 20%;
}

However, the border is covering part of the gif.

Covered gif

1 Answers

Put the image inside a div and it works perfectly.

.img-box {
  background-color: #66BFBF;
  border-radius: 100%;
  width: 150px;
  padding: 23px;
}

.code-img {
  width: inherit;
}
<div class='img-box'>
  <img src="https://media.giphy.com/media/WFZvB7VIXBgiz3oDXE/giphy.gif" class="code-img" alt="Code">
</div>

Related