带箭头流程进度条

本文介绍的是利用纯CSS的带箭头流程进度条,兼容到IE8,需要的朋友们下面来一起学习学习。

首先写出一个基本的样式。

1

2

3

4

5

6

7

8

.cssNav li{ 

    padding: 0px 20px;  

    line-height: 40px

    background: #50abe4

    display: inline-block;  

    color: #fff

    position: relative;
     float: left;
     margin: 1px; 

}

接下来使用 :after 伪类画出一个三角形,定位到右边,如下:

1

2

3

4

5

6

7

8

9

10

.cssNav li:after{ 

    content: ''

    display: block

    border-top: 20px solid red

    border-bottom: 20px solid red

    border-left: 20px solid blue

    position: absolute;  

    rightright: -20px;  

    top: 0

}

然后将after的颜色修改下,基本的雏形已经看到了。

1

2

3

4

5

6

7

8

9

10

11

.cssNav li:after{ 

    content: ''

    display: block

    border-top: 20px solid transparent

    border-bottom: 20px solid transparent

    border-left: 20px solid #50abe4

    position: absolute;  

    rightright: -20px;  

    top: 0

    z-index: 10

}

继续使用 :before 伪类来画出左边的三角形。如下:

1

2

3

4

5

6

7

8

9

10

.cssNav li:before{ 

    content: ''

    display: block

    border-top: 20px solid red

    border-bottom: 20px solid red

    border-left: 20px solid blue

    position: absolute;  

    left: 0px;  

    top: 0

}

然后修改下before的颜色,并复制多个模块看看。

最后把开头和结尾的稍微修饰一下。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

.cssNav li:first-child{   

    border-radius: 4px 0 0 4px;   

    padding-left: 25px

}   

.cssNav li:last-child,.cssNavEnd{   

    border-radius: 0px 4px 4px 0px;   

    padding-right: 25px

}   

.cssNav li:first-child:before{   

    display: none;   

}   

.cssNav li:last-child:after,.cssNavEnd:after{   

    display: none;   

}

加上选中状态,大功告成。

1

2

3

4

5

6

.cssNav li.active { 

    background-color: #ef72b6

.cssNav li.active:after { 

    border-left-color: #ef72b6

}

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。

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;
        }
/*适配小型的箭头导航-结束*/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值