我想要动态地更改CSS遮罩图像的“mask-position”属性。遮罩图像本身是一个简单的渐变,我的预期行为是通过更改遮罩位置的值,使得背景对象从左到右淡入。然而,这个属性是否可以被动画化呢?如果不能,是否有解决方法?
.header-image figure {
mask-image: url("http://thehermitcrab.org/wp-content/themes/the-hermit-theme/images/gradient-mask-straight.png");
animation: clip-fade 3s;
}
@keyframes clip-fade {
0% {mask-position: 100% 0%;}
100% {mask-position: 0% 0%;}
}
HTML:
<div class="header-image">
<figure>
<img src="https://thehermitcrab.org/wp-content/themes/the-hermit-theme/images/footer/crab-footer-chalk-logo.png"/>
</figure>
</div>