Make an element's width relative to its height?

后端 未结 1 1394
陌清茗
陌清茗 2021-02-05 21:35

I know that it\'s possible to specify an element\'s height relative to its width, because percentage margin and padding values are calculated relative to its width. Is it possib

1条回答
  •  悲&欢浪女
    2021-02-05 22:02

    I found one way to do this without Javascript. Make an image with the ratio, and embed it into the HTML, scaling it accordingly, so that the parent element can inline-block fit to the image size.

    
    

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