Resize and crop image with CSS

前端 未结 6 1959
有刺的猬
有刺的猬 2021-01-12 13:37

I\'d like to resize and crop an image of unknown dimensions, just with css. The image should be resized/cropped to completely fill a container of known dimensions, cutting o

6条回答
  •  天涯浪人
    2021-01-12 14:16

    Instead of an you could give the div a background and set background-size: cover.

    css:

    background-image: url("yourimage"); background-size:cover; background-position:center center;

提交回复
热议问题