2 回答

TA貢獻2036條經驗 獲得超8個贊
你可以研究mix-blend-mode
CSS屬性。這里我只是分享了一個例子。您應該深入了解混合。
.container {
? position: relative;
? width: 400px;
}
.wrapper {
? display: flex;
??
}
.left {
? background: #463c84;
? height: 100vh;
? width: 50%;
}
.right {
? background: white;
? width: 50%;
}
.header {
? flex: 1;
? position: absolute;
? top: 20%;
? left: 21%;
? background: inherit;
}
.header h1 {
? color: #fff;
? mix-blend-mode: difference;
}
<div class="container">
? <div class="wrapper">
? ? <div class="left"></div>
? ? <div class="right"></div>
? </div>
? <div class="header">
? ? <h1 class="blend">TEXT WITH INPIRATION</h1>
? </div>
</div>

TA貢獻1788條經驗 獲得超4個贊
您還可以使用background漸變和background-clip. 自定義 CSS var(可以方便地為可重用的代碼設置這些顏色:
例子with a filter hue-rotate to show different colors
:root {
/* set both gradient colors */
--color1: #453C84;
--color2: #ffffff;
/* color to use where background-clip is involved */
--blend: transparent;
}
body {
margin: 0;
}
.split-colors {
height: 100vh;
display: flex;
background: linear-gradient(to right, var(--color1) 50%, var(--color2) 50%);
}
h1 {
margin: auto;
background: linear-gradient(to right, var(--color2) 50%, var(--color1) 50%);
color: var(--blend);
background-clip: text;
}
html {
background: white;
animation: hue-rotate 5s infinite;
}
@keyframes hue-rotate {
50%{
filter: hue-rotate(180deg)
}
}
<div class="split-colors">
<h1>TEXT WITH<br> INSPIRATION</h1>
</div>
添加回答
舉報