渐变动画上的SVG面膜

发布于 2025-01-30 01:52:07 字数 1191 浏览 1 评论 0原文

您好,我尝试了所有事情,但是找不到错误。

我的背景上有一个CSS梯度动画,并希望在上面戴口罩。面具由屏幕中央的一个圆圈组成。 我希望在后台运行的动画只能在圆圈内看到。

到目前为止,这是我的代码:

@charset "utf-8";

body {
margin: 0;
background: #ffffff;
overflow: hidden;
}

.background {
background: linear-gradient(-45deg, #f2e167, #c0a1d3, #dce0a8);
background-size: 400% 400%;
animation: gradient 7s ease infinite;
height: 100vh;
width: 100vw;
z-index:-2;
}

.mask1 {
mask-image: url(assets/images/mask.svg);
mask-repeat: no-repeat;    
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>MAE</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

    <div class="mask1">
      <div class="background"></div>
  </div>

</body>
</html>

动画运行良好,但我看不到面具。

感谢您的帮助。

Hello i tried out everything but don´t find the error.

I have a css gradient-animation running on my background and would like to put a mask over it. The mask consists of a circle in the centre of the screen.
I would like that the animation running in the background is only visible inside the circle.

This is my code so far:

@charset "utf-8";

body {
margin: 0;
background: #ffffff;
overflow: hidden;
}

.background {
background: linear-gradient(-45deg, #f2e167, #c0a1d3, #dce0a8);
background-size: 400% 400%;
animation: gradient 7s ease infinite;
height: 100vh;
width: 100vw;
z-index:-2;
}

.mask1 {
mask-image: url(assets/images/mask.svg);
mask-repeat: no-repeat;    
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>MAE</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

    <div class="mask1">
      <div class="background"></div>
  </div>

</body>
</html>

The animation is running fine but i don´t see the mask.

Thanks for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我很坚强 2025-02-06 01:52:08

这样的东西?

@charset "utf-8";

body {
margin: 0;
background: #ffffff;
overflow: hidden;
}

.background {
background: linear-gradient(-45deg, #f2e167, #c0a1d3, #dce0a8);
background-size: 400% 400%;
animation: gradient 7s ease infinite;
height: 100vh;
width: 100vw;
z-index:-2;
}

.mask1 {
-webkit-mask-image: radial-gradient(circle, black 50%, rgb(0 0 0 / 0%) 50%);  
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}
 <div class="mask1">
      <div class="background"></div>
  </div>

Something like this?

@charset "utf-8";

body {
margin: 0;
background: #ffffff;
overflow: hidden;
}

.background {
background: linear-gradient(-45deg, #f2e167, #c0a1d3, #dce0a8);
background-size: 400% 400%;
animation: gradient 7s ease infinite;
height: 100vh;
width: 100vw;
z-index:-2;
}

.mask1 {
-webkit-mask-image: radial-gradient(circle, black 50%, rgb(0 0 0 / 0%) 50%);  
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}
 <div class="mask1">
      <div class="background"></div>
  </div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文