3

I'm looking for a way to keep the aspect ratio of a div fixed. I already found posts like this:

But these posts always expect the width to be given. I would like to specify a fixed ratio and then specify either height or width.

Examples:

<div class=fixed_ratio style="width: 50px;"></div>
<div class=fixed_ratio style="height: 50px;"></div>

Let's say the fixed_ratio-class uses a fixed ratio of 1:5. The two lines above should result in two div's (50px/250px, 10px/50px).

Is this even possible without javascript?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
  • Given a width - you can produce a height of a specific aspect ratio... but given a height to produce a width - I don't think this is possible without javascript – Danield Sep 29 '16 at 10:12

0 Answers0