JSFiddle - React, Tailwind, and code Playground
by Vadim
HTML
<div class="hero">
<div class="header">Lorem ipsum dollar sit ammet</div>
<div class="body">
<p class="text">Left Side</p>
<div class="card"><img src="https://picsum.photos/id/238/200/300" alt=""></div>
</div>
<div class="overlay"></div>
</div>
CSS
* {
box-sizing: border-box;
}
html, body {
height: 100%;
color: white;
}
body {
margin: 0;
font-family: 'Arial', sans-serif;
position: relative;
background-image: url('https://picsum.photos/id/237/800/600');
background-size: cover;
}
.hero {
width: 100%;
height: 100%;
display: flex;
flex-wrap: wrap;
padding: 50px;
}
/* весь этот псевдоэлемент нужен чтобы задать подложку между фоновой картинкой и контентом. */
.hero::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: black; /* выбираем цвет подложки, инвертированный, то есть чёрный = белый, синиый = красный и тд */
z-index: -1; /* прячем под текст */
clip-path: polygon(50% 0%, 72% 0, 100% 0, 100% 100%, 71% 100%, 46% 100%, 21% 100%, 0 100%, 0 0, 27% 0); /* изначальная обрезка отсутствует, точки находятся по периметру. */
animation-name: flowDown; /* анимация обрезки. */
animation-duration: 6s;
animation-fill-mode: forwards; /* говорим анимации остановиться в конечном состоянии */
}
.header {
width: 100%;
}
.body {
width: 100%;
padding: 50px;
display: flex;
justify-content: space-around;
}
.text {
font-size: 100px;
font-weight: bold;
text-transform: uppercase;
}
.card {
border-radius: 20px;
overflow: hidden;
box-shadow: 1px 1px 2px 2px tomato;
display: flex;
flex-shrink: 0;
position: relative; /* поднимаем карточку по z-index чтобы на неё не влияло инвертирование и изменение фона */
z-index: 1;
}
/* "верхни" слой стекания, который собственно и инвертирует наш текст по цвету */
.overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(255,255,255,0); /* можно сделать менее прозрачным и поставить другой цвет, окажет влияние на цвет текста */
/* z-index: -1; */
clip-path: polygon(50% 0%, 72% 0, 100% 0, 100% 100%, 71% 100%, 46% 100%, 21% 100%, 0 100%, 0 0, 27% 0);
backdrop-filter: invert(1); /* собственно -...