Skip to content

Instantly share code, notes, and snippets.

@jonas-johansson
Created May 23, 2024 08:15
Show Gist options
  • Save jonas-johansson/cf699c4c04cbc5b3a67ce44951d85787 to your computer and use it in GitHub Desktop.
Save jonas-johansson/cf699c4c04cbc5b3a67ce44951d85787 to your computer and use it in GitHub Desktop.
Auto size SVG between header and footer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SVG Full Height</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet" />
</head>
<body class="flex flex-col h-screen">
<header class="bg-blue-500 text-white p-4">
<h1 class="text-center text-2xl">Header</h1>
</header>
<main class="flex-grow flex items-center justify-center overflow-hidden">
<div class="flex items-center justify-center w-full h-full">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid meet" style="object-fit: contain; width: 100%; height: 100%">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>
</div>
</main>
<footer class="bg-blue-500 text-white p-4">
<p class="text-center">Footer</p>
</footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment