<section class="advantages" data-snippet="Advantages">
<div class="advantages__grid">
<article class="advantage advantage--fullwidth">
<h2>Pulvinar arcu ipsum dictumst</h2>
<h3>
Laoreet facilisis
</h3>
</article>
<article class="advantage" style="--_delay: 0.1s;">
<h4>Libero molestie inceptos varius quam</h4>
<p>Massa consectetur nec phasellus odio ridiculus ut condimentum orci et id suscipit molestie aliquet nisi felis
dictumst nibh dui purus eu nam nunc aenean potenti est vulputate elementum curae pellentesque natoque hac
consequat mus
lacinia class ipsum viverra lacus eros.</p>
</article>
<article class="advantage" style="--_delay: 0.2s;">
<h4>Facilisi rutrum convallis mi cubilia nisi ex nulla vitae netus curae.</h4>
<p>Odio ex platea a consectetur laoreet suspendisse sagittis elit, in dapibus vestibulum tortor condimentum neque
varius
venenatis, ut et etiam fames phasellus magna donec.</p>
</article>
<article class="advantage" style="--_delay: 0.3s;">
<h4>Elementum ante laoreet luctus curae ullamcorper est sodales metus.</h4>
<p>Consectetur hendrerit magna fusce nibh et nisi sapien class urna pellentesque neque suscipit rutrum, ut
venenatis
cras auctor aliquam porttitor eros ultrices tincidunt aenean commodo.</p>
</article>
</div>
<figure class="advantages__image">
<img src="./person.png" width="4302" height="2868" alt="Alt text" loading="lazy" />
</figure>
</section>
.advantages {
--_radius: 16px;
display: grid;
grid-template-columns: 2fr max(20vw, 30em);
align-items: flex-end;
background-image: linear-gradient(#efefef, #f9f9f9);
border-radius: var(--_radius);
.in-viewport& .advantages__grid .advantage {
opacity: 1;
transform: none;
}
.in-viewport& .advantages__image {
transform: none;
}
.advantages__image {
position: relative;
top: -3rem;
margin-bottom: -3rem;
grid-row: 1/2;
grid-column: 2/3;
z-index: 1;
display: none;
@media (prefers-reduced-motion: no-preference) {
transform: translateX(1em);
will-change: transform;
transition: transform 0.5s ease-in;
}
& picture,
& img {
width: 100%;
height: auto;
}
@media screen and (min-width:1024px) {
display: block;
}
}
.advantages__grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 2rem;
align-self: flex-start;
padding: 2rem;
grid-column: 1/-1;
@media screen and (min-width:1024px) {
grid-column: 1/2;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
padding: 4rem;
}
.advantage {
--_delay: 0s;
@media (prefers-reduced-motion: no-preference) {
opacity: 0;
transform: translateY(1em);
transition: all 0.3s var(--_delay) ease-in;
will-change: opacity, transform;
}
.advantage--fullwidth& {
margin-bottom: 2rem;
grid-column: 1/-1;
}
}
}
}
class Advantages {
observer = null
element = null
constructor(element) {
this.element = element
this.initAnimation()
}
initAnimation() {
this.observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
const target = entry.target;
if (entry.isIntersecting) {
target.classList.add("in-viewport");
} else {
target.classList.remove("in-viewport");
}
});
}, {
threshold: 0.4
});
this.observer.observe(this.element);
}
}
const element = document.querySelector('.advantages');
new Advantages(element);
<div class="card">
<div class="card__inner">
<h2>Lorem Ipsum sit dolor!</h2>
<p>Mattis id vehicula velit dolor commodo curabitur nascetur dapibus dignissim cras dui quam sodales enim hac platea
quis est dis</p>
<a href="#" class="button">Nullam vestibulum</a>
</div>
</div>
.card {
--mouse-x: 0px;
--mouse-y: 0px;
background: #1a1a1a;
border-radius: 16px;
color: #fff;
min-height: 30ch;
padding: 32px;
position: relative;
transition: scale 0.2s ease-out;
box-shadow: 0 1em 4em rgba(0 0 0 /0.1);
overflow: hidden;
display: flex;
}
.card .card__inner {
display: flex;
flex-direction: column;
gap: 1rem;
align-items: flex-start;
position: relative;
z-index: 2;
}
.card:hover {
scale: 1.03;
}
.card:hover::after {
opacity: 0.1;
}
.card::after {
content: "";
z-index: 1;
background: rgba(255, 255, 255, 0.2) var(--grain);
inset: 0;
position: absolute;
opacity: 0;
mix-blend-mode: screen;
background-blend-mode: screen;
-webkit-mask-image: radial-gradient(500px circle at var(--mouse-x) var(--mouse-y), rgba(0 0 0 / 1), transparent 70%);
mask-image: radial-gradient(500px circle at var(--mouse-x) var(--mouse-y), rgba(0 0 0 / 1), transparent 70%);
transition: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
constructor(element) {
this.element = element
this.init();
}
onMouseMove(e) {
const bounds = this.element.getBoundingClientRect();
const x = e.clientX - bounds.left;
const y = e.clientY - bounds.top;
this.element.style.setProperty('--mouse-x', `${x}px`);
this.element.style.setProperty('--mouse-y', `${y}px`);
}
addEvents() {
this.element.addEventListener('mousemove', (e) => this.onMouseMove(e))
}
init() {
this.addEvents()
}
}
const element = document.querySelector('.card');
new AnimateMouseFocus(element);