Пожалуйста, проверьте изображение ниже.
Я хочу добавить белый цвет текста на черном фоне и черный цвет на текст на белом фоне.
<section className= "greeting">
<div className="hello">
<span>Hey There!</span>
</div>
<div className="color"></div>
</section>
body{
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #f4f4f4;
}
.hello {
height: 100vh;
width: 100vw;
font-family: "Poppins", cursive;
font-size: 10em;
padding: 18vw 42vh;
mix-blend-mode: difference;
display: flex;
justify-content: center;
align-items: center;
}
.color {
z-index: -100;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: none;
height: 100vh;
width: 50vw;
background-color: #101010;
}
Я пробовал смешанный режим смешивания, но он, похоже, не работает.
пожалуйста помоги
Решение проблемы
Вот решение согласно вашему изображению
HTML-код
<div class="abWhiteAndBlack">
<div className="hello">
<span>Hey There!</span>
</div>
</div>
CSS
.abWhiteAndBlack {
background-image: linear-gradient(90deg, black 50%, blue 50%);
height: 300px;
width: 300px;
margin-bottom: 80px;
align-items: center;
display: flex;
}
.hello {
color: gray;
text-align: center;
width: 100%;
font-size: 50px;
}
Для других вариантов, таких как горизонтальный или диагональный, перейдите по следующей ссылке https://stackoverflow.com/a/47135366/18331761.
Комментариев нет:
Отправить комментарий