Jak na to - vystřižený text
Naučte se, jak vytvořit responzivní výřez/vyseknutý text pomocí CSS.
Vyříznutý text (nebo vyříznutý text) je průhledný text, který se zobrazuje jako vyříznutý na obrázku na pozadí:
PŘÍRODA
Poznámka: Tento příklad nefunguje v Internet Exploreru nebo Edge.
Jak vytvořit text výřezu
Krok 1) Přidejte HTML:
Příklad
<div class="image-container">
<div class="text">NATURE</div>
</div>
Krok 2) Přidejte CSS:
Tato mix-blend-mode
vlastnost umožňuje přidat do obrázku text výřezu. Není však podporován v IE nebo Edge:
Příklad
.image-container {
background-image: url("img_nature.jpg");
/* The image used - important! */
background-size: cover;
position: relative; /* Needed to position
the cutout text in the middle of the image */
height: 300px; /* Some
height */
}
.text {
background-color: white;
color: black;
font-size: 10vw;
/* Responsive font size */
font-weight: bold;
margin: 0 auto; /* Center the text container */
padding: 10px;
width: 50%;
text-align: center; /* Center text */
position: absolute; /* Position text */
top: 50%; /* Position text in the middle */
left: 50%; /* Position
text in the middle */
transform: translate(-50%, -50%); /* Position text in the middle */
mix-blend-mode: screen;
/* This makes the cutout text possible */
}
Pokud chcete černý kontejnerový text, změňte režim prolnutí na „násobení“ a barvu pozadí na černou a barvu na bílou:
Příklad
.text {
background-color: black;
color: white;
mix-blend-mode:
multiply;
....
}