本文介绍的是利用纯CSS的带箭头流程进度条,兼容到IE8,需要的朋友们下面来一起学习学习。
首先写出一个基本的样式。
1 2 3 4 5 6 7 8 |
|
接下来使用 :after 伪类画出一个三角形,定位到右边,如下:
1 2 3 4 5 6 7 8 9 10 |
|
然后将after的颜色修改下,基本的雏形已经看到了。
1 2 3 4 5 6 7 8 9 10 11 |
|
继续使用 :before 伪类来画出左边的三角形。如下:
1 2 3 4 5 6 7 8 9 10 |
|
然后修改下before的颜色,并复制多个模块看看。
最后把开头和结尾的稍微修饰一下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
加上选中状态,大功告成。
1 2 3 4 5 6 |
|
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
20220721
最终源码
.navs {
margin:0;
}
.navs .navs-item {
padding: 0px 10px 0 30px;
line-height: 40px;
background: #50abe4;
display: inline-block;
color: #fff;
position: relative;
float: left;
margin: 2px;
}
.navs .navs-item:after {
content: '';
display: block;
border-top: 20px solid #50abe4;
border-bottom: 20px solid #50abe4;
border-left: 20px solid #fff;
position: absolute;
right: -20px;
top: 0;
}
.navs .navs-item:after {
content: '';
display: block;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 20px solid #50abe4;
position: absolute;
right: -20px;
top: 0;
z-index: 10;
}
.navs .navs-item:before {
content: '';
display: block;
border-top: 20px solid #50abe4;
border-bottom: 20px solid #50abe4;
border-left: 20px solid #fff;
position: absolute;
left: 0px;
top: 0;
}
.navs .navs-item:first-child {
border-top-left-radius:4px!important;
border-top-right-radius:0px;
border-bottom-right-radius:0px;
border-bottom-left-radius:4px!important;
padding-left: 25px!important;
}
.navs .navs-item:last-child,
.cssNavEnd {
border-radius: 0px 4px 4px 0px;
padding-right: 25px;
}
.navs .navs-item:first-child:before {
display: none;
}
.navs .navs-item:last-child:after,
.cssNavEnd:after {
display: none;
}
.navs .navs-item.active {
background-color: #ef72b6;
}
.navs .navs-item.active:after {
border-left-color: #ef72b6;
}
引用html
<div class="navs">
<span class="navs-item">超级管理员</span>
<span class="navs-item">超级管理员</span>
<span class="navs-item">超级管理员</span>
</div>
如果觉得箭头过大,这个变小一点的css
/*适配小型的箭头导航-开始*/
.navs .navs-item {
line-height: 27px;
}
.navs .navs-item:before {
border-top: 15px solid #50abe4;
border-bottom: 12px solid #50abe4;
}
.navs .navs-item:after {
border-top: 15px solid transparent;
border-bottom: 12px solid transparent;
}
/*适配小型的箭头导航-结束*/