1 回答
TA贡献1798条经验 获得超7个赞
这是一个如何执行此操作的小演示:
document.querySelector('.image').addEventListener('mousemove', ({ offsetX, offsetY, target }) => {
const x = offsetX / target.clientWidth;
const y = offsetY / target.clientHeight;
target.style.setProperty('--x', `${x * 100}%`);
target.style.setProperty('--y', `${y * 100}%`);
});
.image {
width: 640px;
height: 200px;
position: relative;
}
.image::before, .image::after {
content: '';
display: block;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-image: var(--image);
}
.image::before {
filter: blur(10px);
}
.image::after {
clip-path: circle(20% at var(--x, 50%) var(--y, 50%));
z-index: 1;
}
<div class="image" style="--image: url(https://picsum.photos/id/862/640/200)"><div>
添加回答
举报