Media Between Text
Inside the headline a photo slides open between two words once the hero is in view; when closed, a narrow orange slot remains. A click closes or opens it. For a hero with a mood image but no big photo band.
Trappen die passen.
Timmerwerkplaats in Gouda. Elke trap op maat getekend, gezaagd en geplaatst.
How to use it
- Paste the HTML where the hero styles should appear.
- Add the CSS to your stylesheet. All classes are prefixed, so nothing clashes with your own styles.
- Add the JavaScript and call init() with the element that contains the HTML.
<!-- Media Between Text · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie -->
<div class="jouw-container">
<div class="nmb">
<h3 class="nmb__kop">Trappen <button class="nmb__vlak" type="button" aria-expanded="false" aria-label="Foto tonen"><img class="nmb__img" src="https://neddev.com/lab-media/cases-filter-masonry-3.webp" alt="Eiken trap met laden in de onderste treden"></button> die passen.</h3>
<p class="nmb__sub">Timmerwerkplaats in Gouda. Elke trap op maat getekend, gezaagd en geplaatst.</p>
</div>
</div>/* Media Between Text · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie */
.nmb{width:100%;padding:0 5%;box-sizing:border-box;container-type:inline-size;font-family:'Switzer',sans-serif;color:#0a0a0a}
.nmb__kop{margin:0;font-weight:700;font-size:clamp(30px,10.5cqw,128px);line-height:.98;letter-spacing:-.035em}
.nmb__vlak{--open:2.3em;position:relative;display:inline-block;vertical-align:-.06em;width:max(24px,.26em);height:max(24px,.76em);margin:0 .06em;padding:0;border:0;font:inherit;border-radius:4px;background:#F5480F;overflow:hidden;cursor:pointer;transition:width .7s cubic-bezier(.65,0,.2,1)}
.nmb__vlak[aria-expanded="true"]{width:var(--open)}
.nmb__vlak:focus-visible{outline:3px solid #0a0a0a;outline-offset:3px}
.nmb__img{position:absolute;top:0;left:50%;width:var(--open);height:100%;object-fit:cover;transform:translateX(-50%) scale(1.15);opacity:0;transition:opacity .4s ease .15s,transform .9s cubic-bezier(.3,.8,.2,1)}
.nmb__vlak[aria-expanded="true"] .nmb__img{opacity:1;transform:translateX(-50%) scale(1)}
.nmb__sub{margin:18px 0 0;font-size:clamp(14px,1.6cqw,18px);color:#5b5750;max-width:44ch}
@media (prefers-reduced-motion:reduce){.nmb__vlak,.nmb__img{transition:none}}// Media Between Text · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie
// root = het element waarin de HTML staat
function init(root){
var w = root.querySelector('.nmb'); if (!w) return;
var vlak = w.querySelector('.nmb__vlak');
function zet(open) { vlak.setAttribute('aria-expanded', open ? 'true' : 'false'); vlak.setAttribute('aria-label', open ? 'Foto verbergen' : 'Foto tonen'); }
vlak.addEventListener('click', function () { zet(vlak.getAttribute('aria-expanded') !== 'true'); });
if ('IntersectionObserver' in window) {
var io = new IntersectionObserver(function (items) {
items.forEach(function (it) { if (it.isIntersecting) { setTimeout(function () { zet(true); }, 350); io.disconnect(); } });
}, { threshold: 0.4 });
io.observe(w);
} else zet(true);
}
init(document.querySelector('.jouw-container'));
More hero styles
Seen something you like?
Add it to your selection and send it over. We build your site around it, in your brand.
Get in touch →