Fill a div with an image respecting aspect ratio

后端 未结 4 1822
悲哀的现实
悲哀的现实 2020-12-04 03:51

Is it possible to fill a div with an image such that at least one image dimension is 100% and the other dimension is either wider or equal size as the div, whilst r

4条回答
  •  暖寄归人
    2020-12-04 03:55

    You could set the images as the div's backgrounds instead and use backkground-size:cover

    https://jsfiddle.net/3x5x0v24/

提交回复
热议问题