Fejlécek
Réteges editorial
Élő előnézet – a komponens teljes méretben.
Élő előnézet
HTML · CSS · JS
<div class="we-editorial-hero">
<div class="we-editorial-panels" aria-hidden="true">
<div class="we-editorial-panel"></div>
<div class="we-editorial-panel"></div>
<div class="we-editorial-panel"></div>
<div class="we-editorial-panel"></div>
<div class="we-editorial-panel"></div>
</div>
<div class="we-editorial-overlay"></div>
<div class="we-editorial-content">
<span class="we-editorial-kicker">KÜLÖNLEGES TÖRTÉNETEK</span>
<h1>
A világ<br>
másik oldala
</h1>
<p>
Fedezd fel a részleteket, amelyek egy pillanatot
emlékezetessé tesznek.
</p>
<a href="#" class="we-editorial-button">
Felfedezem
<span class="we-editorial-arrow">→</span>
</a>
</div>
<div class="we-editorial-bottom">
<span>14 / 24</span>
<span class="we-editorial-line"></span>
<span>Görgess tovább</span>
</div>
</div>
@import url('https://fonts.googleapis.com/css2?family=Bodoni+Moda:opsz,wght@6..96,400;6..96,500;6..96,600&family=DM+Sans:wght@400;500;600&display=swap');
.we-editorial-hero {
--we-editorial-image:
url("https://images.unsplash.com/photo-1500534623283-312aade485b7?auto=format&fit=crop&w=2200&q=90");
position: relative;
width: 100%;
min-height: 720px;
overflow: hidden;
isolation: isolate;
background: #080b11;
color: #fff;
font-family: "DM Sans", sans-serif;
}
/* =========================================
KÉPPANELEK
========================================= */
.we-editorial-panels {
position: absolute;
inset: 0;
display: flex;
z-index: 1;
transform: scale(1.06);
}
.we-editorial-panel {
position: relative;
flex: 1;
height: 100%;
overflow: hidden;
background-image: var(--we-editorial-image);
background-size: 500% 100%;
background-repeat: no-repeat;
opacity: 0;
transform: translateY(100%);
transition:
transform 1.15s cubic-bezier(.77, 0, .18, 1),
opacity .6s ease;
}
/*
* A kép öt részre van bontva.
* Mindegyik panel a kép saját részét mutatja.
*/
.we-editorial-panel:nth-child(1) {
background-position: 0% center;
}
.we-editorial-panel:nth-child(2) {
background-position: 25% center;
}
.we-editorial-panel:nth-child(3) {
background-position: 50% center;
}
.we-editorial-panel:nth-child(4) {
background-position: 75% center;
}
.we-editorial-panel:nth-child(5) {
background-position: 100% center;
}
/* =========================================
SÖTÉT RÉTEG
========================================= */
.we-editorial-overlay {
position: absolute;
inset: 0;
z-index: 2;
background:
linear-gradient(
90deg,
rgba(5, 8, 13, .82) 0%,
rgba(5, 8, 13, .56) 42%,
rgba(5, 8, 13, .18) 100%
),
linear-gradient(
180deg,
rgba(5, 8, 13, .08) 0%,
rgba(5, 8, 13, .05) 55%,
rgba(5, 8, 13, .72) 100%
);
pointer-events: none;
}
/* =========================================
TARTALOM
========================================= */
.we-editorial-content {
position: relative;
z-index: 4;
width: min(1180px, calc(100% - 70px));
min-height: 720px;
margin: 0 auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
padding: 70px 0 110px;
opacity: 0;
transform: translateY(28px);
transition:
opacity 1s ease .95s,
transform 1.1s cubic-bezier(.22, 1, .36, 1) .95s;
}
.we-editorial-kicker {
display: inline-flex;
align-items: center;
gap: 13px;
margin-bottom: 25px;
color: rgba(255, 255, 255, .72);
font-size: 11px;
font-weight: 600;
letter-spacing: .25em;
}
.we-editorial-kicker::before {
content: "";
width: 38px;
height: 1px;
background: #fff;
opacity: .65;
}
.we-editorial-content h1 {
max-width: 850px;
margin: 0;
font-family: "Bodoni Moda", Georgia, serif;
font-size: clamp(64px, 9vw, 132px);
font-weight: 500;
line-height: .9;
letter-spacing: -.045em;
}
.we-editorial-content p {
max-width: 480px;
margin: 30px 0 35px;
color: rgba(255, 255, 255, .78);
font-size: 16px;
line-height: 1.8;
}
/* =========================================
GOMB
========================================= */
.we-editorial-button {
display: inline-flex;
align-items: center;
gap: 22px;
padding: 15px 20px 15px 24px;
border: 1px solid rgba(255, 255, 255, .55);
color: #fff;
background: rgba(255, 255, 255, .07);
backdrop-filter: blur(10px);
text-decoration: none;
font-size: 12px;
font-weight: 600;
letter-spacing: .14em;
text-transform: uppercase;
transition:
background .35s ease,
border-color .35s ease,
transform .35s ease;
}
.we-editorial-arrow {
width: 34px;
height: 34px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: #fff;
color: #080b11;
font-size: 18px;
transition: transform .35s ease;
}
.we-editorial-button:hover {
color: #fff;
border-color: #fff;
background: rgba(255, 255, 255, .15);
transform: translateY(-3px);
}
.we-editorial-button:hover .we-editorial-arrow {
transform: translateX(5px);
}
/* =========================================
ALSÓ INFORMÁCIÓ
========================================= */
.we-editorial-bottom {
position: absolute;
z-index: 5;
left: 50%;
bottom: 34px;
width: min(1180px, calc(100% - 70px));
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 16px;
color: rgba(255, 255, 255, .58);
font-size: 10px;
letter-spacing: .16em;
text-transform: uppercase;
}
.we-editorial-line {
width: 70px;
height: 1px;
background: rgba(255, 255, 255, .38);
}
/* =========================================
BETÖLTÉSI ÁLLAPOT
========================================= */
.we-editorial-hero.is-loaded .we-editorial-panel {
opacity: 1;
transform: translateY(0);
}
.we-editorial-hero.is-loaded .we-editorial-panel:nth-child(1) {
transition-delay: .05s;
}
.we-editorial-hero.is-loaded .we-editorial-panel:nth-child(2) {
transition-delay: .14s;
}
.we-editorial-hero.is-loaded .we-editorial-panel:nth-child(3) {
transition-delay: .23s;
}
.we-editorial-hero.is-loaded .we-editorial-panel:nth-child(4) {
transition-delay: .32s;
}
.we-editorial-hero.is-loaded .we-editorial-panel:nth-child(5) {
transition-delay: .41s;
}
.we-editorial-hero.is-loaded .we-editorial-content {
opacity: 1;
transform: translateY(0);
}
/* =========================================
MOBIL
========================================= */
@media (max-width: 700px) {
.we-editorial-hero {
min-height: 650px;
}
.we-editorial-content {
width: calc(100% - 40px);
min-height: 650px;
padding: 60px 0 100px;
}
.we-editorial-content h1 {
font-size: clamp(54px, 16vw, 82px);
}
.we-editorial-content p {
font-size: 14px;
line-height: 1.7;
}
.we-editorial-bottom {
width: calc(100% - 40px);
bottom: 24px;
}
.we-editorial-bottom span:last-child {
display: none;
}
.we-editorial-line {
flex: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.we-editorial-panel,
.we-editorial-content,
.we-editorial-button,
.we-editorial-arrow {
transition: none;
}
}
document.querySelectorAll(".we-editorial-hero").forEach(hero => {
const panels = hero.querySelectorAll(".we-editorial-panel");
requestAnimationFrame(() => {
setTimeout(() => {
hero.classList.add("is-loaded");
}, 120);
});
hero.addEventListener("mousemove", event => {
const rect = hero.getBoundingClientRect();
const x = (event.clientX - rect.left) / rect.width;
const y = (event.clientY - rect.top) / rect.height;
const moveX = (x - 0.5) * 10;
const moveY = (y - 0.5) * 6;
panels.forEach((panel, index) => {
const depth = (index - 2) * 0.8;
panel.style.marginTop = `${moveY * depth}px`;
panel.style.marginLeft = `${moveX * depth}px`;
});
});
hero.addEventListener("mouseleave", () => {
panels.forEach(panel => {
panel.style.marginTop = "0";
panel.style.marginLeft = "0";
});
});
});