新增第177个小实例:悬停带提示的导航栏

This commit is contained in:
DESKTOP-BM6RJU5\wyanh 2022-08-04 17:55:51 +08:00
parent 3e161a19c9
commit da660e38d7
3 changed files with 163 additions and 1 deletions

View File

@ -183,4 +183,5 @@
173. HTML5+CSS3+JS小实例交互式图片鼠标悬停景深对焦效果
174. HTML5+CSS3+JS小实例简约的黑色分页
175. HTML5+CSS3小实例带功能区的图片悬停特效
176. HTML5+CSS3+Vue小实例输入框打字放大特效
176. HTML5+CSS3+Vue小实例输入框打字放大特效
177. HTML5+CSS3小实例悬停带提示的导航栏

93
code/177/177.css Normal file
View File

@ -0,0 +1,93 @@
*{
/* 初始化 */
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
/* 方便演示 满屏居中 */
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: #f2f5f7;
}
.icon-nav{
list-style: none;
background-color: #231f2e;
padding: 0 12px 12px 12px;
/* 弹性布局 垂直排列 */
display: flex;
flex-direction: column;
/* 均匀排列每个元素 首个元素在起点 末尾元素在终点 */
justify-content: space-between;
border-radius: 10px;
/* 阴影 */
box-shadow: 0 10px 50px rgba(6,5,59,0.25);
}
.icon-nav li{
margin-top: 12px;
}
/* 分割线 */
.icon-nav li.split{
margin-top: 80px;
padding-top: 20px;
border-top: 1px solid rgba(255,255,255,0.15);
}
.icon-nav a{
color: #fff;
text-decoration: none;
display: flex;
justify-content: center;
align-items: center;
width: 48px;
height: 48px;
border-radius: 8px;
position: relative;
}
.icon-nav a i{
font-size: 20px;
}
/* 提示层 */
.icon-nav a span{
position: absolute;
/* 计算位置 */
left: calc(100% + 24px);
background-color: #fa5c51;
font-size: 15px;
/* 不换行 */
white-space: nowrap;
padding: 8px 16px;
border-radius: 6px;
/* 默认隐藏 */
transform: scale(0);
opacity: 0;
/* 设置基点 */
transform-origin: center left;
/* 设置过渡 */
transition: 0.15s ease;
}
/* 提示层 小三角 */
.icon-nav a span::before{
content: "";
width: 12px;
height: 12px;
background-color: #fa5c51;
position: absolute;
left: -5px;
top: 50%;
border-radius: 3px;
transform: translateY(-50%) rotate(45deg);
}
.icon-nav a:hover,
.icon-nav a:focus,
.icon-nav a:active{
background-color: #fa5c51;
outline: none;
}
.icon-nav a:hover span,
.icon-nav a:focus span,
.icon-nav a:active span{
transform: scale(1);
opacity: 1;
}

68
code/177/177.html Normal file
View File

@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>悬停带提示的导航栏</title>
<!-- 引入font-awesome字体图标库 -->
<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
<link rel="stylesheet" href="177.css">
</head>
<body>
<ul class="icon-nav">
<li>
<a href="#">
<i class="fa fa-home"></i>
<span>首页</span>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-product-hunt"></i>
<span>产品管理</span>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-user-circle"></i>
<span>会员管理</span>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-shopping-bag"></i>
<span>订单管理</span>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-credit-card-alt"></i>
<span>财务中心</span>
</a>
</li>
<!-- 分割线 -->
<li class="split">
<a href="#">
<i class="fa fa-bell"></i>
<span>消息</span>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-gear"></i>
<span>系统配置</span>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-user"></i>
<span>用户中心</span>
</a>
</li>
</ul>
</body>
</html>