<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>纯CSS实现内凹导航栏</title>
<link href="https://at.alicdn.com/t/c/font_179247_uja3277echo.css" type="text/css" rel="stylesheet" />
<style type="text/css">
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f0f0f0;
}
.nav{
width: 375px;
height: 70px;
padding: 0 15px;
border-radius: 5px;
background-color: #fff;
position: relative;
display: flex;
}
.nav dd{
width: 70px;
height: 70px;
position: relative;
list-style: none;
cursor: pointer;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 10;
}
.nav dd i{
display: block;
position: relative;
height: 70px;
line-height: 70px;
text-align: center;
font-size: 24px;
transition: all 0.5s;
}
.nav dd span{
position:absolute;
font-size: 12px;
letter-spacing: 2px;
transition: all 0.5s;
opacity: 0;
transform: translateY(20px);
}
.nav dd.on i{
transform: translateY(-35px);
color: #ffffff;
}
.nav dd.on span{
opacity: 1;
transform: translateY(10px);
}
.indicator{
position:absolute;
top: -50%;
width: 70px;
height: 70px;
background-color: #ff6a00;
border-radius: 50%;
transition: all 0.5s;
border: 6px solid #f0f0f0;
}
.indicator::before{
content: '';
position: absolute;
top: 50%;
left: -23px;
width: 21px;
height: 21px;
border-top-right-radius: 20px;
box-shadow: 1px -10px 0 0 #f0f0f0;
}
.indicator::after{
content: '';
position: absolute;
top: 50%;
right: -23px;
width: 21px;
height: 21px;
border-top-left-radius: 20px;
box-shadow: -1px -10px 0 0 #f0f0f0;
}
dd:nth-child(1).on~.indicator{
transform: translateX(calc(70px * 0));
}
dd:nth-child(2).on~.indicator{
transform: translateX(calc(70px * 1));
}
dd:nth-child(3).on~.indicator{
transform: translateX(calc(70px * 2));
}
dd:nth-child(4).on~.indicator{
transform: translateX(calc(70px * 3));
}
dd:nth-child(5).on~.indicator{
transform: translateX(calc(70px * 4));
}
</style>
</head>
<body>
<dl class="nav">
<dd class="on"><i class="iconfont icon-shouye1"></i><span>首页</span></dd>
<dd><i class="iconfont icon-zixun"></i><span>资讯</span></dd>
<dd><i class="iconfont icon-fabu"></i><span>发布</span></dd>
<dd><i class="iconfont icon-xiaoxi"></i><span>消息</span></dd>
<dd><i class="iconfont icon-wode"></i><span>我的</span></dd>
<dt class="indicator"></dt>
</dl>
<script>
const $dd = document.querySelectorAll('.nav dd');
$dd.forEach((item,index)=>{
item.addEventListener('click',function(){
$dd.forEach((_dd,_index)=>{
_dd.classList.remove('on');
this.classList.add('on');
})
})
})
</script>
</body>
</html>

我赚够三千万就收手
- 粉丝: 6288
最新资源
- 支路电气介数Matlab仿真研究:HVDC、FACTS(TCSC与UPFC)模型的选择与对比 · Matlab仿真 参考
- 我的自己总结的知识点总结
- 基于GA遗传优化的混合发电系统(Matlab)优化配置算法:风力、光伏与蓄电池发电
- 基于PI控制的PMSM永磁同步电机Simulink建模与仿真技术研究 - Matlab2022a版
- 基于PSO优化的MPPT光伏发电系统Simulink仿真:构建与优化详解 · MATLAB 文档
- 基于MATLAB的车辆行驶控制运动学模型建模与仿真及其应用 - MATLAB (2025-07-28)
- 基于Simulink的Flyback反激型电路建模与仿真:Matlab 2022a版全流程解析
- 电力系统负荷损失与潮流计算matlab仿真下的节点攻击对比研究:最高度数、最高介数及最高关键度的停电规模评估
- 100KW三相光伏并网逆变器设计方案:原理图、PCB、源码及元器件详解 故障保护 深度版
- 基于Copula函数的风光联合场景生成与K-means聚类削减算法研究
- COMSOL冻土水热耦合模型:PDE建模与降水入渗的入门指南
- 基于springboot的车辆充电桩系统_join1375.zip
- ADC建模与数字校准:基于MATLAB的模数转换器及模拟IC设计实践教程
- 基于SMIC18EE工艺的24位高精度Sigma Delta ADC调制器电路设计学习包
- 复现OEA顶刊论文:紧聚焦矢量光束激发纳米颗粒MIe散射物理模型,多极分解与任意矢量光设置和激发
- 基于FLAC3D点安全系数法的边坡安全系数计算与软件内置强度折减法的对比分析 · FLAC3D 2025版
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


