Vissza a webes elemekhez
Fejlécek

Kettős fókusz

Élő előnézet – a komponens teljes méretben.

Élő előnézet
HTML · CSS · JS
HTML
<section class="hero-split">

    <div class="hero-split-content">

        <div class="hero-split-copy">

            <div class="hero-split-kicker">
                <span class="hero-split-kicker-line"></span>
                Új perspektíva
            </div>

            <h1>
                Másképp<br>
                <span>látni.</span>
            </h1>

            <p>
                Merész ötletek, átgondolt részletek és
                digitális megoldások egyetlen különleges
                élménnyé formálva.
            </p>

            <div class="hero-split-actions">
                <a href="#" class="hero-split-primary">
                    Ismerd meg
                    <span>→</span>
                </a>

                <a href="#" class="hero-split-secondary">
                    Projektjeink
                </a>
            </div>

        </div>


        <div class="hero-split-visual">

            <div class="hero-split-image">
                <img
                    src="https://images.unsplash.com/photo-1497366811353-6870744d04b2?auto=format&fit=crop&w=1400&q=85"
                    alt="Modern belső tér"
                >
            </div>

            <div class="hero-split-image-tag">
                <span>01</span>
                <span>Design / Space</span>
            </div>

            <div class="hero-split-floating-card">
                <strong>01</strong>
                <div>
                    <span>Gondolat</span>
                    <span>Forma</span>
                    <span>Élmény</span>
                </div>
            </div>

        </div>

    </div>

</section>
CSS
/* ==========================================
   HERO 02 — KETTŐS FÓKUSZ
   ========================================== */

.hero-split {
    --split-dark: #17201d;
    --split-light: #e8e5df;
    --split-accent: #c48a62;
    --split-muted: #9c9b94;

    position: relative;
    width: 100%;
    min-height: 720px;

    overflow: hidden;

    background: var(--split-light);
    color: var(--split-dark);

    font-family: "DM Sans", sans-serif;
}


.hero-split-content {
    position: relative;

    width: min(1440px, 90%);
    min-height: 720px;

    margin: 0 auto;

    display: grid;
    grid-template-columns: 46% 54%;

    align-items: center;
}


/* ==========================================
   BAL OLDAL
   ========================================== */

.hero-split-copy {
    position: relative;
    z-index: 4;

    padding: 80px 0;
}


.hero-split-kicker {
    display: flex;
    align-items: center;
    gap: 14px;

    margin-bottom: 32px;

    color: var(--split-muted);

    font-size: 11px;
    font-weight: 600;

    text-transform: uppercase;
    letter-spacing: 2.5px;

    opacity: 0;
    transform: translateX(-30px);

    animation: splitTextIn .8s .1s ease forwards;
}


.hero-split-kicker-line {
    width: 42px;
    height: 1px;

    background: var(--split-accent);
}


.hero-split h1 {
    margin: 0 0 32px;

    font-family: Georgia, "Times New Roman", serif;

    font-size: clamp(76px, 8.2vw, 128px);
    font-weight: 400;

    line-height: .83;
    letter-spacing: -6px;

    opacity: 0;
    transform: translateX(-45px);

    animation: splitTextIn 1s .2s ease forwards;
}


.hero-split h1 span {
    color: var(--split-accent);

    font-style: italic;
}


.hero-split-copy > p {
    width: min(430px, 90%);

    margin: 0 0 38px;

    color: #656760;

    font-size: 16px;
    line-height: 1.75;

    opacity: 0;
    transform: translateX(-35px);

    animation: splitTextIn .9s .35s ease forwards;
}


/* ==========================================
   GOMBOK
   ========================================== */

.hero-split-actions {
    display: flex;
    align-items: center;
    gap: 28px;

    opacity: 0;
    transform: translateY(20px);

    animation: splitUp .8s .5s ease forwards;
}


.hero-split-primary {
    display: inline-flex;
    align-items: center;
    gap: 24px;

    padding: 17px 23px;

    background: var(--split-dark);
    color: #fff;

    text-decoration: none;

    font-size: 13px;

    transition:
        background .3s ease,
        transform .3s ease;
}


.hero-split-primary span {
    font-size: 20px;
    line-height: 0;

    transition: transform .3s ease;
}


.hero-split-primary:hover {
    background: var(--split-accent);

    transform: translateY(-3px);
}


.hero-split-primary:hover span {
    transform: translateX(5px);
}


.hero-split-secondary {
    position: relative;

    color: var(--split-dark);

    text-decoration: none;

    font-size: 13px;
}


.hero-split-secondary::after {
    content: "";

    position: absolute;

    left: 0;
    bottom: -6px;

    width: 100%;
    height: 1px;

    background: var(--split-dark);

    transform-origin: right;
    transform: scaleX(1);

    transition: transform .35s ease;
}


.hero-split-secondary:hover::after {
    transform-origin: left;
    transform: scaleX(0);
}


/* ==========================================
   JOBB OLDALI KÉP
   ========================================== */

.hero-split-visual {
    position: relative;

    height: 100%;

    display: flex;
    align-items: center;

    padding-left: 30px;
}


.hero-split-image {
    position: relative;

    width: 100%;
    height: min(74vh, 650px);

    overflow: hidden;

    opacity: 0;
    transform: translateX(90px);

    animation:
        splitImageIn 1.2s .15s
        cubic-bezier(.16,1,.3,1)
        forwards;
}


.hero-split-image::before {
    content: "";

    position: absolute;
    z-index: 2;

    inset: 0;

    background:
        linear-gradient(
            90deg,
            rgba(232,229,223,.18),
            transparent 30%
        );

    pointer-events: none;
}


.hero-split-image img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: cover;

    transform: scale(1.12);

    animation:
        splitImageScale 1.7s .2s
        cubic-bezier(.16,1,.3,1)
        forwards;

    transition: transform 1.2s ease;
}


.hero-split-image:hover img {
    transform: scale(1.045);
}


/* ==========================================
   KÉP CÍMKE
   ========================================== */

.hero-split-image-tag {
    position: absolute;

    z-index: 5;

    left: 10px;
    bottom: 35px;

    display: flex;
    align-items: center;
    gap: 14px;

    color: #fff;

    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.8px;

    opacity: 0;

    animation: splitFade .8s 1s ease forwards;
}


.hero-split-image-tag span:first-child {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 34px;
    height: 34px;

    border: 1px solid rgba(255,255,255,.55);

    border-radius: 50%;
}


/* ==========================================
   LEBEGŐ KÁRTYA
   ========================================== */

.hero-split-floating-card {
    position: absolute;

    z-index: 6;

    left: -65px;
    bottom: 105px;

    width: 190px;

    padding: 22px;

    background: var(--split-dark);
    color: #fff;

    box-shadow: 0 20px 50px rgba(0,0,0,.18);

    display: flex;
    gap: 18px;

    opacity: 0;
    transform: translateY(30px);

    animation:
        splitCardIn .8s .75s
        cubic-bezier(.16,1,.3,1)
        forwards;
}


.hero-split-floating-card strong {
    font-family: Georgia, serif;

    font-size: 28px;
    font-weight: 400;

    color: var(--split-accent);
}


.hero-split-floating-card div {
    display: flex;
    flex-direction: column;
    gap: 5px;

    padding-top: 2px;
}


.hero-split-floating-card span {
    color: rgba(255,255,255,.68);

    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
}


/* ==========================================
   ANIMÁCIÓK
   ========================================== */

@keyframes splitTextIn {

    to {
        opacity: 1;
        transform: translateX(0);
    }

}


@keyframes splitUp {

    to {
        opacity: 1;
        transform: translateY(0);
    }

}


@keyframes splitImageIn {

    to {
        opacity: 1;
        transform: translateX(0);
    }

}


@keyframes splitImageScale {

    to {
        transform: scale(1);
    }

}


@keyframes splitCardIn {

    to {
        opacity: 1;
        transform: translateY(0);
    }

}


@keyframes splitFade {

    to {
        opacity: 1;
    }

}


/* ==========================================
   TABLET
   ========================================== */

@media (max-width: 1050px) {

    .hero-split-content {
        grid-template-columns: 1fr;

        padding: 80px 0;

        gap: 65px;
    }


    .hero-split-copy {
        padding: 0;
    }


    .hero-split-visual {
        padding-left: 0;
    }


    .hero-split-image {
        height: 520px;
    }


    .hero-split-floating-card {
        left: -25px;
    }

}


/* ==========================================
   MOBIL
   ========================================== */

@media (max-width: 650px) {

    .hero-split {
        min-height: auto;
    }


    .hero-split-content {
        width: 88%;

        padding: 65px 0 80px;

        gap: 55px;
    }


    .hero-split h1 {
        font-size: clamp(66px, 18vw, 90px);

        letter-spacing: -4px;
    }


    .hero-split-copy > p {
        font-size: 15px;
    }


    .hero-split-actions {
        gap: 20px;
    }


    .hero-split-image {
        height: 430px;
    }


    .hero-split-floating-card {
        left: -10px;
        bottom: 70px;

        width: 165px;

        padding: 18px;
    }


    .hero-split-image-tag {
        left: 15px;
    }

}


/* ==========================================
   MOZGÁS CSÖKKENTÉSE
   ========================================== */

@media (prefers-reduced-motion: reduce) {

    .hero-split *,
    .hero-split *::before,
    .hero-split *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }

}
JavaScript
/* ==========================================
   HERO 02 — KETTŐS FÓKUSZ
   ========================================== */

document.addEventListener("DOMContentLoaded", () => {

    const hero = document.querySelector(".hero-split");

    if (!hero) return;


    const image = hero.querySelector(".hero-split-image img");
    const card = hero.querySelector(".hero-split-floating-card");


    if (
        !image ||
        !window.matchMedia("(pointer: fine)").matches
    ) {
        return;
    }


    hero.addEventListener("mousemove", (event) => {

        const rect = hero.getBoundingClientRect();

        const x =
            (event.clientX - rect.left) /
            rect.width - 0.5;

        const y =
            (event.clientY - rect.top) /
            rect.height - 0.5;


        image.style.transform =
            `scale(1.045) translate(${x * -10}px, ${y * -10}px)`;


        if (card) {

            card.style.transform =
                `translate(${x * 7}px, ${y * 7}px)`;

        }

    });


    hero.addEventListener("mouseleave", () => {

        image.style.transform =
            "scale(1) translate(0, 0)";


        if (card) {
            card.style.transform = "";
        }

    });

});