Skip to content

Instantly share code, notes, and snippets.

@Darksecond
Created October 22, 2018 08:08
Show Gist options
  • Save Darksecond/788e9062a02f686c6fb185ac1c3a3d37 to your computer and use it in GitHub Desktop.
Save Darksecond/788e9062a02f686c6fb185ac1c3a3d37 to your computer and use it in GitHub Desktop.
Proper HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Game</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<canvas class="flow" width="320" height="180"></canvas>
</body>
</html>
:root {
--aspect-width: 16;
--aspect-height: 9;
}
body {
margin: 0;
padding: 0;
background-color: #111;
}
.flow {
width: 100vw;
height: 100vh;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: calc(100vh*var(--aspect-width)/var(--aspect-height));
max-height: calc(100vw*var(--aspect-height)/var(--aspect-width));
}
canvas {
background-color: black;
image-rendering: pixelated;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment