Can I use for both height and width-constrained images?

后端 未结 1 1783
独厮守ぢ
独厮守ぢ 2021-01-18 14:28

I have a slideshow sort of thing where images will expand as large as they can, but not exceed the viewport\'s width or height. Basically object-fit: contain.

1条回答
  •  有刺的猬
    2021-01-18 14:47

    I think I got it (1/2) is equal to (width/height):

    
    

    Or with more code:

    
    

    As a side note: I also have written a script that automatically calculates the right sizes for parent height/width constrained sizes. See here the parent-fit script.

    0 讨论(0)
提交回复
热议问题