1

I want to make an image round (circle) from CSS, but, when I use border-radius: 50%; my image goes ellipsoidal.

I expect to output a responsive circle with that image.

How I can do that?

Thanks!

#image {
  width: 100%;
  border-radius: 50%;
}
<div id="main">
  
  <figure id="img-div">
    <img id="image" src="https://wallpaperaccess.com/full/486693.jpg" alt="A bulb that represent electricity">
  </figure>
  
</div>
kevx
  • 79
  • 9

3 Answers3

1

You need to set the same height and width in order for an element to be a circle.

#image {
  width: 150px;
  height: 150px;
  border-radius: 50%;
}
<div id="main">
  
  <figure id="img-div">
    <img id="image" src="https://wallpaperaccess.com/full/486693.jpg" alt="A bulb that represent electricity">
  </figure>
  
</div>
KLTR
  • 1,263
  • 2
  • 14
  • 37
  • Ok, I got this, but now the image will be no more responsive, right? I want to keep that circle image responsive. – kevx Sep 12 '19 at 14:09
1

You can do it by resizing your image just make your image same height and width like below..

this is only another way you can do it..

#image {
  width: 100%;
  border-radius: 50%;
}
<div id="main">
  
  <figure id="img-div">
    <img id="image" src="https://i.stack.imgur.com/q2ola.jpg" alt="A bulb that represent electricity">
  </figure>
  
</div>
sbrrk
  • 896
  • 1
  • 7
  • 10
1

Your image needs to be square to obtain this result.

You can use this : How to "crop" a rectangular image into a square with CSS? to keep it square and responsive.

After that, you radius will make it circle.

Dimitri Bosteels
  • 381
  • 4
  • 12