CSS Circular Cropping of Rectangle Image

前端 未结 9 1388
北荒
北荒 2020-12-12 15:32

I want to make a centered circular image from rectangle photo. The photo\'s dimensions is unknown. Usually it\'s a rectangle form. I\'ve tried a lot of methods:

CSS:

9条回答
  •  星月不相逢
    2020-12-12 16:04

    You need to use jQuery to do this. This approach gives you the abbility to have dynamic images and do them round no matter the size.

    My demo has one flaw right now I don't center the image in the container, but ill return to it in a minute (need to finish a script I'm working on).

    DEMO

    lambo
    //script var container = $('.container'), image = container.find('img'); container.width(image.height()); //css .container { height: auto; overflow: hidden; border-radius: 50%; } .image { height: 100%; display: block; }

提交回复
热议问题