首页 > 开发 > CSS > 正文

css实现流程导航效果(三种方法)

2024-07-11 08:33:32
字体:
来源:转载
供稿:网友

css实现流程导航效果,具体内容如下所示:

::tip 使用纯css线上 流程导航效果。    本文统一采取 flex 布局 ,你也可以采用其他布局实现,核心原理不变 :::  

## 方法一 利用裁剪  该方法IE下不支持

利用裁剪 clip-path: polygon(),直接画出一个三角 唯一一点需要算出大致百分比就可以画出来  


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<style>
.nav-box {
display: flex;
list-style: none;
font-size: 14px;
}
.nav-box li {
white-space: nowrap;
color: #019fe9;
background: #edf9ff;
counter-increment: listCounter;
clip-path: polygon(87% 0, 100% 50%, 87% 100%, 0 100%, 13% 50%, 0 0);
line-height: 40px;
padding: 0 25px;
margin-right: -10px;
}
.nav-box li::before {
content: counter(listCounter) "-";
}
.nav-box .active {
color: #fcfefe;
background: #009fe9;
}
.nav-box .active ~ li {
color: #8e8e8e;
background: #ebedf0;
}
</style>
</head>
<body>
<!-- 容器 -->
<ol class="nav-box">
<li><a href="">规则说明</a></li>
<li><a href="">参与活动</a></li>
<li class="active" aria-current="true"><a href="">参与抽奖</a></li>
<li><a href="">奖品发放</a></li>
<li><a href="">查看结果</a></li>
</ol>
</body>
</html>

## 方法二 利用错位

flex + transform : skewX(); 实现  ie9+ 状况下使用前缀 -ms- + 这个方法也完全利用里before after, + 原理1 — 利用 before + after 分成上下半区 <Badge text="【这种方法有个缺陷就是要单独补全第一个的尾巴】" type="warn"/> + 原理2 — 利用 before + after 分成左右半区 <Badge text="【该方法只对第一个before 或 after做处理避免第一个的问题】" type="success"/>


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<style scoped>
.nav-box {
display: flex;
list-style: none;
font-size: 14px;
}
.nav-box li {
white-space: nowrap;
color: #019fe9;
padding: 0 15px 0 25px;
line-height: 40px;
margin-left: 3px;
position: relative;
z-index: 99;
}
.nav-box li:first-child{
background: #edf9ff;
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表