css - css中多级导航栏的平滑悬停效果
问题描述
我有一个纯 CSS 中的多阶段圆形导航栏。我想实现悬停效果,但工作不顺利。它非常生涩和丑陋。怎么让它光滑?
我们是否也可以对悬停产生影响,使蓝色球从 0 逐渐增加到全宽,然后在它周围出现一个白色圆圈?
#stages_cont {
margin:50px auto;
width:600px;
}
#stages {
background:#d4d7df;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
height:5px;
}
#stages li {
float:left;
text-align:center;
width:33%;
}
#stages li a {
-moz-border-radius:50%;
-webkit-border-radius:50%;
border-radius:50%;
display:block;
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
text-decoration:none;
}
.stage_done .stage_circle {
background:#2585fe;
border:6px solid #ffffff;
box-shadow:0px 0px 5px #d4d7df;
height:20px;
width:20px;
margin:-13px auto 10px;
}
.stage_not .stage_circle {
background:#d4d7df;
height:20px;
width:20px;
margin:-8px auto 17px;
-moz-transition:all 0.5s ease;
-webkit-transition:all 0.5s ease;
transition:all 0.5s ease;
}
.stage_done .stage_link {
color:#2585fe;
}
.stage_not .stage_link {
color:#d4d7df;
}
.clr {
clear:both;
}
.stage_not:hover .stage_circle {
background:#2585fe;
border:6px solid #ffffff;
box-shadow:0px 0px 5px #d4d7df;
margin:-13px auto 10px;
}
<link rel="stylesheet" type="text/css" href="https://meyerweb.com/eric/tools/css/reset/reset.css" />
<div id="stages_cont">
<ul id="stages">
<li class="stage_done">
<a class="stage_circle" href="#"></a>
<a class="stage_link" href="#">Details</a>
</li>
<li class="stage_done">
<a class="stage_circle" href="#"></a>
<a class="stage_link" href="#">Content</a>
</li>
<li class="stage_not">
<a class="stage_circle" href="#"></a>
<a class="stage_link" href="#">Send or Schedule</a>
</li>
<div class="clr"></div>
</ul>
</div>
解决方案
更新以下样式
.stage_not .stage_circle {
background: #d4d7df;
height: 20px;
width: 20px;
margin: -8px auto 17px;
-moz-transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
transition: all 0.5s ease;
box-sizing: border-box;
}
.stage_not:hover .stage_circle {
background: #2585fe;
border: 6px solid #ffffff;
box-shadow: 0px 0px 5px #d4d7df;
margin: -13px auto 10px;
box-sizing: border-box;
height: 32px;
width: 32px;
}
#stages_cont {
margin: 50px auto;
width: 600px;
}
#stages {
background: #d4d7df;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
height: 5px;
}
#stages li {
float: left;
text-align: center;
width: 33%;
}
#stages li a {
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
display: block;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
text-decoration: none;
}
.stage_done .stage_circle {
background: #2585fe;
border: 6px solid #ffffff;
box-shadow: 0px 0px 5px #d4d7df;
height: 20px;
width: 20px;
margin: -13px auto 10px;
}
.stage_not .stage_circle {
background: #d4d7df;
height: 20px;
width: 20px;
margin: -8px auto 17px;
-moz-transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
transition: all 0.5s ease;
box-sizing: border-box;
}
.stage_done .stage_link {
color: #2585fe;
}
.stage_not .stage_link {
color: #d4d7df;
}
.clr {
clear: both;
}
.stage_not:hover .stage_circle {
background: #2585fe;
border: 6px solid #ffffff;
box-shadow: 0px 0px 5px #d4d7df;
margin: -13px auto 10px;
box-sizing: border-box;
height: 32px;
width: 32px;
}
<link rel="stylesheet" type="text/css" href="https://meyerweb.com/eric/tools/css/reset/reset.css" />
<div id="stages_cont">
<ul id="stages">
<li class="stage_done">
<a class="stage_circle" href="#"></a>
<a class="stage_link" href="#">Details</a>
</li>
<li class="stage_done">
<a class="stage_circle" href="#"></a>
<a class="stage_link" href="#">Content</a>
</li>
<li class="stage_not">
<a class="stage_circle" href="#"></a>
<a class="stage_link" href="#">Send or Schedule</a>
</li>
<div class="clr"></div>
</ul>
</div>
推荐阅读
- asp.net-core - net::ERR_CONNECTION_REFUSED 尝试使用 SixLabors.ImageSharp.Web 从 azure blob 容器获取图像时
- azure - 如何将来自 Azure 事件中心(kafka 接口)的事件集成到谷歌云发布/订阅
- java - 我可以使用 java.time 等从 zoneId 获取国家代码吗?
- php - Shopware 6:为产品创建继承的实体扩展
- php - 如果直到稍后才加载自动加载,我的 index.php 文件如何知道如何使用类?
- continuous-integration - Gitlab CI/CD:尚未连接新运行器
- node.js - node_module如何解决依赖关系
- python - 当绘制两个数据集并且其中一个具有更多数据时,我们如何“规范化”它们以使它们在表示上相等?
- go - 测试 kubernetes go client api 调用时通过 FieldSelector spec.nodeName 过滤 Pod 的方式
- angular - 如何动态创建角度 ag-grids