<!-- Invisible SVG -->
<svg viewBox="0 0 600 300" class="svg-defs">
<!-- Symbol with text -->
<symbol id="s-text">
<text text-anchor="middle"
x="50%" y="50%" dy=".35em"
class="text"
>
Text
</text>
</symbol>
<!-- Mask with text -->
<mask id="m-text"
maskunits="userSpaceOnUse"
maskcontentunits="userSpaceOnUse">
<rect
width="100%"
height="100%"
class="mask__shape">
</rect>
<use xlink:href="#s-text"
class="mask__text"
></use>
</mask>
</svg>
<div class="box-with-text">
<!-- Content for text -->
<div class="text-fill"></div>
<!-- SVG to cover text fill -->
<svg viewBox="0 0 600 300"
class="svg-inverted-mask">
<!-- Big shape with hole in form of text -->
<rect
width="100%"
height="100%"
mask="url(#m-text)"
class="shape--fill"/>
<!-- Transparent copy of text to keep
patterned text selectable -->
<use xlink:href="#s-text"
class="text--transparent"
></use>
</svg>
</div>
/* Main styles */
@import url(http://fonts.googleapis.com/css?family=Open+Sans:800);
.svg-inverted-mask {
position: absolute;
width: 100%;
height: 100%;
}
.mask__shape {
fill: white;
}
.box-with-text {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
/* Visible fill of text */
.text-fill {
position: absolute;
top: 50%;
left: 50%;
padding-top: 35vw;
padding-left: 100%;
margin: auto;
overflow: hidden;
transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
background: url(https://img-fotki.yandex.ru/get/5600/yoksel.5c/0_46792_5ffcddbd_orig) 50% 50%/cover;
}
/* Fill of inverted mask */
.shape--fill {
fill: #fff6cc;
}
/* Transparent copy of text to keep
patterned text selectable */
.text--transparent {
fill: transparent;
}
@media (min-aspect-ratio: 2 / 1) {
.text-fill {
padding-top: 70vh;
padding-left: 190vh;
}
}
/* Other stuff */
html, body {
height: 100%;
}
body {
background: #fff6cc;
font: 14.5em/1 Open Sans, Impact;
text-transform: uppercase;
margin: 0;
}
.svg-defs {
width: 0;
height: 0;
}