Skip to content

Instantly share code, notes, and snippets.

@nasitra
Created November 14, 2017 11:07
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 nasitra/6eda1319033c13607bfc876bb9f71158 to your computer and use it in GitHub Desktop.
Save nasitra/6eda1319033c13607bfc876bb9f71158 to your computer and use it in GitHub Desktop.
Responsively change div size keeping aspect ratio
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
body {
margin: 0;
}
.content {
background-color: green;
bottom: 0;
height: 56.25vw;
left: 0;
margin: auto;
max-height: 100vh;
max-width: 100vw;
position: absolute;
right: 0;
top: 0;
width: 177.78vh;
}
</style>
</head>
<body>
<div class="content"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment