效果展示:
CSS 中mix-blend-mode: difference;实现 属性反色展示效果
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style type="text/css">
*{
margin: 0;
padding: 0;
}
.container {
position: relative;
width: 500px; /* 按照实际情况设置宽度 */
}
.logo {
position: fixed;
top: 0;
left: 0;
z-index: 1; /* 使 logo 在图片上方 */
color: #fff; /* 设置 logo 文字的颜色为白色 */
font-size: 36px;
font-weight: bold;
text-transform: uppercase;
mix-blend-mode: difference; /* 使用 mix-blend-mode 属性实现颜色反转效果 */
transition: color 0.3s ease; /* 设置过渡效果,使变化更加平滑 */
}
</style>
<div class="container">
<img src="https://img-blog.csdnimg.cn/47f119243ad644988f3627aeac8db268.jpeg#pic_center">
<div style="width: 100%;height: 560px;background-color: red;"></div>
<div style="width: 100%;height: 560px;background-color: #000000;"></div>
<div style="width: 100%;height: 560px;background-color: #CCCCCC;"></div>
<div style="width: 100%;height: 560px;background-color: #FFFFFF;"></div>
<div style="width: 100%;height: 560px;background-color: #FFFFFF;"></div>
<div class="logo"><img src="https://img-blog.csdnimg.cn/1ee5097edfef4bf9b0bfb43f68790b29.png#pic_center" alt=""></div>
</div>