<header>
<div class="hero__content">
<h1>Product</h1>
<p>You really need this product, so hurry and buy it today!</p>
<a href="#" class="button">Buy Now</a>
</div>
<img src="https://assets.codepen.io/1101822/happy-bunch2.png" alt="Illustration from the Happy Bunch collection by Pablos Stanley">
</header>
$primary: #3c87b3;
$secondary: #2ba27c;
header {
display: grid;
grid-template-areas: "hero";
align-items: center;
height: 65vh;
max-height: 600px;
background-color: mix(#fff, $primary, 97%);
> * {
grid-area: hero;
}
img {
object-fit: cover;
object-position: 5vw -5vmin;
height: min(65vh, 600px);
// Chrome no longer preventing growing beyond
// the header height with just the following
// height: 100%;
width: 80%;
justify-self: end;
transition: 180ms width ease-in;
@media (min-width: 60rem) {
width: 60%;
}
}
.hero__content {
margin: 1rem 0 1rem 5%;
max-width: 35%;
min-width: 30ch;
z-index: 1;
background-color: rgba(mix(#fff, $primary, 97%), 0.8);
border-radius: 1rem;
padding: 0.5rem 0.5rem 0.5rem 0;
h1 {
font-size: 3rem;
color: #3c87b3;
font-weight: 500;
margin: 0 0 1rem;
}
p {
font-size: 1.75rem;
color: scale-color($primary, $lightness: -5%, $saturation: -60%);
}
}
}
.button {
font-size: 1.125rem;
font-weight: 500;
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
align-self: start;
background-color: $secondary;
color: #fff;
border-radius: 8px;
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.18);
padding: 0.25em 0.75em;
min-width: 10ch;
min-height: 44px;
text-align: center;
line-height: 1.1;
transition: 220ms all ease-in-out;
&:hover,
&:active {
background-color: scale-color($secondary, $lightness: -20%);
}
&:focus {
outline-style: solid;
outline-color: transparent;
box-shadow: 0 0 0 4px scale-color($secondary, $lightness: -40%);
}
}
* {
box-sizing: border-box;
}
body {
min-height: 100vh;
font-family: "Baloo 2", sans-serif;
margin: 0;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.