css实现图片悬浮遮罩动画效果代码

代码语言:html

所属分类:悬停

代码描述:css实现图片悬浮遮罩动画效果代码

代码标签: 悬浮 遮罩 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

 
<meta charset="UTF-8">

 
<style>
* {
 
box-sizing: border-box;
}
body
{
 
min-height: 100vh;
 
display: flex;
 
align-items: center;
 
justify-content: center;
}
.image-container {
 
display: grid;
 
grid-template-columns: repeat(3, 1fr);
 
grid-template-rows: repeat(3, 1fr);
 
width: 600px;
 
grid-gap: 0.5rem;
}
.image-container .image {
 
position: relative;
 
padding-bottom: 100%;
}
.image-container .image img {
 
height: 100%;
 
width: 100%;
 
-o-object-fit: cover;
     
object-fit: cover;
 
left: 0;
 
position: absolute;
 
top: 0;
}
.image-container .image img:nth-of-type(1) {
 
filter: grayscale(1) brightness(40%);
}
.image-container .image img:nth-of-type(2) {
 
-webkit-clip-path: var(--clip-start);
         
clip-path: var(--clip-start);
 
transition: -webkit-clip-path 0.5s;
 
transition: clip-path 0.5s;
 
transition: clip-path 0.5s, -webkit-clip-path 0.5s;
}
.image-container .image:hover img:nth-of-type(2) {
 
-webkit-clip-path: var(--clip-end);
         
clip-path: var(--clip-end);
}
</style>


</head>

<body>
 
<div class="image-container">
 
<div class="image" style="--clip-start: ellipse(0 0 at 0 0); --clip-end: ellipse(150% 150% at 0 0);"><img src="//repo.bfw.wiki/bfwrepo/image/5d6539613d08b.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_200,h_200,/quality,q_90"/><img src="//repo.bfw.wiki/bfwrepo/image/5d6539613d08b.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_200,h_200,/quality,q_90"/></div>
  <div class="image" style="--clip-start: inset(100% .........完整代码请登录后点击上方下载按钮下载查看

网友评论0