Skip to content

Instantly share code, notes, and snippets.

@pbnkp
Created November 11, 2023 06:14
Show Gist options
  • Save pbnkp/f09db61ecaed0aa19586ee2a07943760 to your computer and use it in GitHub Desktop.
Save pbnkp/f09db61ecaed0aa19586ee2a07943760 to your computer and use it in GitHub Desktop.
prefers-reduced-transparency and motion Hero Header (not adaptive)
<!--
see adaptive version: https://codepen.io/argyleink/pen/oNmvVKj
-->
<header class="hero">
<img src="https://assets.codepen.io/2585/marvin-meyer-SYTO3xs06fU-unsplash.jpg" alt="a wooden table is viewed top down where it is covered in laptops, coffee, and cables, appearing to be a table for lots of productivity.">
<div>
<h1>Expedita Voluptatibus</h1>
<p>Vel rerum culpa consequuntur.</p>
<br>
<button>Nobis Loquere</button>
</div>
</header>
@layer demo {
.hero {
display: grid;
overflow: hidden;
> * {
grid-area: 1 / 1;
}
> img {
block-size: 100dvh;
width: 100%;
object-fit: cover;
animation: zoomy 30s ease infinite;
}
> div {
z-index: 1;
color: white;
background: linear-gradient(
to top right in oklab,
oklch(40% 0.3 340 / 70%),
oklch(40% 0.4 200 / 70%)
);
display: grid;
gap: 1ch;
place-content: center;
place-items: center;
}
}
}
@keyframes zoomy {
50% {
scale: 1.1;
}
}
@layer demo.support {
* {
box-sizing: border-box;
margin: 0;
}
html {
block-size: 100%;
color-scheme: light;
}
body {
min-block-size: 100%;
font-family: system-ui, sans-serif;
}
p {
font-size: 1.25rem;
font-weight: 300;
line-height: 1.5;
text-wrap: pretty;
}
img {
max-width: 100%;
}
header h1 {
font-size: 7vw;
}
button {
background: deeppink;
border: none;
border-radius: 5ch;
padding: 1ch 2.5ch;
color: white;
font-size: 1.25rem;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment