CSS-only way to set a div to 90% width and 3:1 aspect ratio [duplicate]
问题 This question already has answers here : Maintain the aspect ratio of a div with CSS (23 answers) Closed 4 years ago . I have a div that I want to set to 90% of its parent container's width, and I want its height to be set so as to achieve a specific aspect ratio, say 3:1. .mydiv { width: 90% height: 30%(of-width); } Is there any way to do this that does not involve JavaScript? 回答1: If your container div has a fixed width, then your 90% width div has as well a fixed width. Look which is this