IE and Edge fix for object-fit: cover;

前端 未结 6 1599
清歌不尽
清歌不尽 2020-11-27 05:54

I\'m using object-fit: cover; in my CSS for images on a specific page, because they need to stick on the same height. It works great in most browse

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 05:54

    I achieved satisfying results with:

    min-height: 100%;
    min-width: 100%;
    

    this way you always maintain the aspect ratio.

    The complete css for an image that will replace "object-fit: cover;":

    width: auto;
    height: auto;
    min-width: 100%;
    min-height: 100%;
    position: absolute;
    right: 50%;
    transform: translate(50%, 0);
    

提交回复
热议问题