<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS3鼠标悬停图标导航动画</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Arial', sans-serif;
}
body {
background: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.nav-container {
display: flex;
background: #fff;
padding: 20px;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
.nav-item {
position: relative;
width: 70px;
height: 70px;
margin: 0 10px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
cursor: pointer;
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.nav-item .icon {
position: relative;
width: 60px;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
background: #fff;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
z-index: 2;
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.nav-item .icon i {
font-size: 24px;
color: #666;
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.nav-item .title {
position: absolute;
top: 0;
font-size: 14px;
background: #fff;
color: #fff;
padding: 5px 10px;
border-radius: 30px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
opacity: 0;
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.nav-item:hover {
transform: translateY(-10px);
}
.nav-item:hover .icon {
background: linear-gradient(45deg, #8e2de2, #4a00e0);
}
.nav-item:hover .icon i {
color: #fff;
}
.nav-item:hover .title {
top: -40px;
opacity: 1;
background: linear-gradient(45deg, #8e2de2, #4a00e0);
}
.nav-item:nth-child(1):hover .icon,
.nav-item:nth-child(1):hover .title {
background: linear-gradient(45deg, #f12711, #f5af19);
}
.nav-item:nth-child(2):hover .icon,
.nav-item:nth-child(2):hover .title {
background: linear-gradient(45deg, #00b09b, #96c93d);
}
.nav-item:nth-child(3):hover .icon,
.nav-item:nth-child(3):hover .title {
background: linear-gradient(45deg, #fc4a1a, #f7b733);
}
.nav-item:nth-child(4):hover .icon,
.nav-item:nth-child(4):hover .title {
background: linear-gradient(45deg, #8e2de2, #4a00e0);
}
.nav-item:nth-child(5):hover .icon,
.nav-item:nth-child(5):hover .title {
background: linear-gradient(45deg, #11998e, #38ef7d);
}
.footer {
position: fixed;
bottom: 20px;
color: #666;
font-size: 12px;
}
.footer a {
color: #4a00e0;
text-decoration: none;
}
/* 插入的网址样式 */
.inserted-link {
display: none;
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>
<body>
<div class="nav-container">
<div class="nav-item">
<div class="icon">
<i class="fas fa-home"></i>
</div>
<span class="title">首页</span>
</div>
<div class="nav-item">
<div class="icon">
<i class="fas fa-search"></i>
</div>
<span class="title">搜索</span>
</div>
<div class="nav-item">
<div class="icon">
<i class="fas fa-heart"></i>
</div>
<span class="title">收藏</span>
</div>
<div class="nav-item">
<div class="icon">
<i class="fas fa-user"></i>
</div>
<span class="title">我的</span>
</div>
<div class="nav-item">
<div class="icon">
<i class="fas fa-cog"></i>
</div>
<span class="title">设置</span>
</div>
</div>
<div class="footer">
版权所有 © 2023
</div>
</body>
</html>
CSS3鼠标悬停图标导航动画
于 2025-06-05 16:20:26 首次发布