Glassmorphism 过渡图标悬停效果
2024-03-14 本文已影响0人
林中白虎
效果展示
微信截图_20240304175113.png页面结构组成
页面结构主要是采用flex
布局来实现图标的布局。动画效果是当鼠标移动到对应的图标上时,图标会上移并且z-index
属性会改为前置一层,视觉上的效果就是在前后移动。
CSS3 知识点
- z-indx 在图标切换时,可以达到层次改变效果
- transition
- transition-delay
页面整体布局
<section>
<!-- 背景颜色区 -->
<div class="color"></div>
<div class="color"></div>
<div class="color"></div>
<!-- 图标区 -->
<ul>
<li>
<a href="#">
<i class="fa fa-qq" aria-hidden="true"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-steam" aria-hidden="true"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-weixin" aria-hidden="true"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-weibo" aria-hidden="true"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-tencent-weibo" aria-hidden="true"></i>
</a>
</li>
</ul>
</section>
实现图标样式
ul {
position: inherit;
z-index: 9;
display: flex;
}
ul li {
list-style: none;
margin: 10px;
}
ul li a {
position: relative;
top: 0;
width: 80px;
height: 80px;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 2em;
border: 1px solid rgba(255, 255, 255, 0.4);
border-right: 1px solid rgba(255, 255, 255, 0.2);
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 10px;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(4px);
z-index: 1;
box-shadow: 0 5px 45px rgba(0, 0, 0, 0.1);
text-decoration: none;
overflow: hidden;
transition: top 0.5s, z-index 0s, transform 0.5s;
transition-delay: 0.5s, 0.5s, 0s;
}
实现图标切换动画
ul li a:hover {
top: -50px;
transform: translateY(50px);
transition-delay: 0s, 0.5s, 0.5s;
z-index: 22;
}
ul li a::before {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 100px;
background: rgba(255, 255, 255, 0.5);
transform: skewX(45deg) translateX(150px);
transition: 0.5s;
}
ul li a:hover::before {
transform: skewX(45deg) translateX(-150px);
}