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>
添加回答
举报