Skip to content

Instantly share code, notes, and snippets.

@humbleRumble
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save humbleRumble/8a56c59989b4bd8b1487 to your computer and use it in GitHub Desktop.
Save humbleRumble/8a56c59989b4bd8b1487 to your computer and use it in GitHub Desktop.

How to force a responsive element to retain its aspect ratio

I have a responsive div that contains a large amount of text and is the same width as its container.

<div>This is a long string of text, but the real text will be a lot longer.</div>

How can I force the div to retain a height which is 50% of its width using only HTML and CSS?

It should look like this

And this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment