Skip to content

Instantly share code, notes, and snippets.

@michaelcpuckett
Last active December 24, 2024 13:27
Show Gist options
  • Select an option

  • Save michaelcpuckett/93dd304da7d1ac1329bb1e8441f13031 to your computer and use it in GitHub Desktop.

Select an option

Save michaelcpuckett/93dd304da7d1ac1329bb1e8441f13031 to your computer and use it in GitHub Desktop.
layout with header and footer
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
<style>
:where(*) {
box-sizing: border-box;
}
html {
display: grid;
height: 100%;
overflow: hidden;
overscroll-behavior: none;
container-name: root;
container-type: inline-size;
}
body {
margin: 0;
overflow: hidden;
overscroll-behavior: none;
display: grid;
grid-template-rows: auto minmax(0px, 1fr) auto;
}
:where(p) {
margin-top: 0;
margin-bottom: 0;
}
.top,
.bottom {
background: #ddd;
}
.top,
p,
.bottom {
padding: 1rem;
padding-left: calc(1rem + env(safe-area-inset-left));
padding-right: calc(1rem + env(safe-area-inset-right));
}
.top {
padding-top: 1rem;
padding-top: calc(1rem + env(safe-area-inset-top));
}
.bottom {
padding-bottom: 1rem;
padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}
p {
height: 100cqh;
background: red;
}
p:last-of-type {
background: blue;
}
.top {
touch-action: none;
}
.middle {
display: grid;
height: 100%;
overflow-y: auto;
container-name: main;
container-type: size;
}
.bottom {
touch-action: none;
}
</style>
</head>
<body>
<div class="top">Header</div>
<div class="middle">
<p>Main</p>
<p>123</p>
</div>
<div class="bottom">Footer</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment