效果图:
代码:
<template>
<div>
<div class="bruce pr flex-ct-x">
<div class="mask-layer"></div>
</div>
</div>
</template>
<script>
export default {
data() {
return {};
},
methods: {},
created() {}
};
</script>
<style lang="scss" scoped>
// 定义变量
$mask-bg: "https://yangzw.vip/static/codepen/mask-bg.jpg";
$mask-text: "https://yangzw.vip/static/codepen/mask-text.jpg";
$logo: "https://yangzw.vip/static/codepen/logo-netease.svg";
.bruce {
overflow: hidden;
&::after {
position: absolute;
left: -20px;
right: -20px;
top: -20px;
bottom: -20px;
// 设置背景图,并加滤镜模糊处理
background: url($mask-bg) no-repeat center/cover;
filter: blur(10px);
content: "";
}
}
.mask-layer {
position: relative;
z-index: 9;
width: 600px;
height: 300px;
background: url($mask-text) left center/150% auto;
mask: url($logo) center/cover;
// infinite(循环)
animation: move 10s infinite;
}
@keyframes move {
0% {
background-position-x: 0;
}
50% {
background-position-x: 100%;
}
}
</style>