Skip to content

Instantly share code, notes, and snippets.

@mqxu
Created November 3, 2019 12:18
Show Gist options
  • Save mqxu/398e36deaeab3488ac14fe06bbb43f23 to your computer and use it in GitHub Desktop.
Save mqxu/398e36deaeab3488ac14fe06bbb43f23 to your computer and use it in GitHub Desktop.
【iCSS:图形】使用mask雕刻镂空背景
<div class="bruce pr flex-ct-x">
<div class="mask-layer"></div>
</div>
$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;
animation: move 10s infinite;
}
@keyframes move {
0% {
background-position-x: 0;
}
50% {
background-position-x: 100%;
}
}
<link href="https://yangzw.vip/static/css/reset.css" rel="stylesheet" />
<link href="https://yangzw.vip/static/css/main.css" rel="stylesheet" />
<link href="https://yangzw.vip/static/css/theme.scss" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment